Class WRowCollection
Represents a collection of WTableRow objects.
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.UWP.dll
Syntax
public class WRowCollection : EntityCollection, IEntityCollectionBase, ICollectionBase, IEnumerable
Examples
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
section.AddParagraph().AppendText("Price Details");
section.AddParagraph();
//Add a new table into Word document
IWTable table = section.AddTable();
//Get the rows collection from table
WRowCollection rowCollection = table.Rows;
//Add the first row into table
WTableRow row = new WTableRow(document);
//Add the first cell into first row
WTableCell cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Item");
//Add the second cell into first row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Price($)");
//Add row to the collection
rowCollection.Add(row);
//Add the second row into table
row = new WTableRow(document);
//Add the first cell into second row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Apple");
//Add the second cell into second row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("50");
//Insert row at index 1
rowCollection.Insert(1, row);
//Add the third row into table
row = new WTableRow(document);
//Add the first cell into third row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Orange");
//Add the second cell into third row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("30");
//Insert row
rowCollection.Insert(2, row);
//Remove row at index 0.
rowCollection.RemoveAt(0);
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
Dim section As IWSection = document.AddSection()
section.AddParagraph().AppendText("Price Details")
section.AddParagraph()
'Add a new table into Word document
Dim table As IWTable = section.AddTable()
'Get the rows collection from table
Dim rowCollection As WRowCollection = table.Rows
'Add the first row into table
Dim row As New WTableRow(document)
'Add the first cell into first row
Dim cell As WTableCell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Item")
'Add the second cell into first row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Price($)")
'Add row to the collection
rowCollection.Add(row)
'Add the second row into table
row = New WTableRow(document)
'Add the first cell into second row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Apple")
'Add the second cell into second row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("50")
'Insert row at index 1
rowCollection.Insert(1, row)
'Add the third row into table
row = New WTableRow(document)
'Add the first cell into third row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Orange")
'Add the second cell into third row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("30")
'Insert row
rowCollection.Insert(2, row)
'Remove row at index 0.
rowCollection.RemoveAt(0)
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
Constructors
WRowCollection(WTable)
Initializes a new instance of the WRowCollection class with the specified WTable instance.
Declaration
public WRowCollection(WTable owner)
Parameters
Type | Name | Description |
---|---|---|
WTable | owner | The WTable instance. |
Properties
Item[Int32]
Gets the table row at the specified index.
Declaration
public WTableRow this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the row to get from the collection. |
Property Value
Type | Description |
---|---|
WTableRow | The WTableRow at the specified index. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | The index is not valid in the WRowCollection. |
TypesOfElement
Gets the type of the elements present in the collection.
Declaration
protected override Type[] TypesOfElement { get; }
Property Value
Type | Description |
---|---|
System.Type[] | The System.Type collection that contains the types of the elements. |
Overrides
Methods
Add(WTableRow)
Adds the specified table row to the collection.
Declaration
public int Add(WTableRow row)
Parameters
Type | Name | Description |
---|---|---|
WTableRow | row | The row. |
Returns
Type |
---|
System.Int32 |
IndexOf(WTableRow)
Returns the index of the specified row in the collection.
Declaration
public int IndexOf(WTableRow row)
Parameters
Type | Name | Description |
---|---|---|
WTableRow | row | The row. |
Returns
Type |
---|
System.Int32 |
Insert(Int32, WTableRow)
Inserts the specified table row at the specified index in the collection.
Declaration
public void Insert(int index, WTableRow row)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index. |
WTableRow | row | The row. |
Remove(WTableRow)
Removes the specified row from the collection.
Declaration
public void Remove(WTableRow row)
Parameters
Type | Name | Description |
---|---|---|
WTableRow | row | The row. |
Implements
System.Collections.IEnumerable