Class TabCollection
Represents a collection of Tab in the paragraph.
Implements
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.NET.dll
Syntax
public class TabCollection : CollectionImpl, IEnumerable
Examples
The following code illustrates the how to add and remove tabs from the TabCollection.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add tab at position 0;
paragraph.ParagraphFormat.Tabs.AddTab();
//Add tab stop at position 11
Tab firstTab = paragraph.ParagraphFormat.Tabs.AddTab(11);
//Add tab stop at position 62, with tab justification and tab leader.
paragraph.ParagraphFormat.Tabs.AddTab(62, TabJustification.Left, TabLeader.Single);
paragraph.AppendText("This sample\t illustrates the use of tabs in the paragraph. Tabs\t can be inserted or removed from the paragraph.");
//Remove tab stop from the collection
paragraph.ParagraphFormat.Tabs.RemoveByTabPosition(11);
//Remove tab at index 0;
paragraph.ParagraphFormat.Tabs.RemoveAt(0);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add tab at position 0;
paragraph.ParagraphFormat.Tabs.AddTab()
'Add tab stop at position 11
Dim firstTab As Tab = paragraph.ParagraphFormat.Tabs.AddTab(11)
'Add tab stop at position 62, with tab justification and tab leader.
paragraph.ParagraphFormat.Tabs.AddTab(62, TabJustification.Left, TabLeader.[Single])
paragraph.AppendText("This sample" & vbTab & " illustrates the use of tabs in the paragraph. Tabs" & vbTab & " can be inserted or removed from the paragraph.")
'Remove tab stop from the collection
paragraph.ParagraphFormat.Tabs.RemoveByTabPosition(11)
'Remove tab at index 0;
paragraph.ParagraphFormat.Tabs.RemoveAt(0)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
Properties
Item[Int32]
Gets the Tab at the specified index. Read-only.
Declaration
public Tab this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the tab. |
Property Value
Type | Description |
---|---|
Tab | The Tab instance. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | The index is not valid in the TabCollection. |
Methods
AddTab()
Adds a new tab at the position 0.
Declaration
public Tab AddTab()
Returns
Type | Description |
---|---|
Tab | The newly added Tab object. |
AddTab(Single)
Adds the tab at the specified position.
Declaration
public Tab AddTab(float position)
Parameters
Type | Name | Description |
---|---|---|
System.Single | position | The position of the tab. |
Returns
Type | Description |
---|---|
Tab | The newly added Tab object. |
AddTab(Single, TabJustification, TabLeader)
Adds the tab at the specified position with the tab justification and tab leader.
Declaration
public Tab AddTab(float position, TabJustification justification, TabLeader leader)
Parameters
Type | Name | Description |
---|---|---|
System.Single | position | The position of the tab. |
TabJustification | justification | The type of tab justification. |
TabLeader | leader | The type of tab leader. |
Returns
Type | Description |
---|---|
Tab | The newly added Tab object. |
Clear()
Removes all the tabs from the tab collection.
Declaration
public void Clear()
RemoveAt(Int32)
Removes the tab at the specified index from the tab collection.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the tab to be removed. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | The index is not valid in the TabCollection. |
RemoveByTabPosition(Double)
Removes the tab present at the specified position from the tab collection.
Declaration
public void RemoveByTabPosition(double position)
Parameters
Type | Name | Description |
---|---|---|
System.Double | position | The position of the tab to be removed. |