title | ms.date | ms.custom | description | dev_langs | helpviewer_keywords | ms.assetid | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
How to: Manipulate a Table's Row Groups through the RowGroups Property |
03/30/2017 |
devdivchpfy22 |
Learn how to manipulate a Table's Row Groups through the RowGroups property. |
|
|
ea61440f-08ae-44ed-b314-5716aaaae3ed |
This example demonstrates some of the more common operations that can be performed on a table's row groups through the xref:System.Windows.Documents.Table.RowGroups%2A property.
The following example creates a new table and then uses the xref:System.Windows.Documents.TableRowGroupCollection.Add%2A method to add columns to the table's xref:System.Windows.Documents.Table.RowGroups%2A collection.
[!code-csharpTableSnippets2#_Table_RowGroups_Add] [!code-vbTableSnippets2#_Table_RowGroups_Add]
The following example inserts a new xref:System.Windows.Documents.TableRowGroup. The new column is inserted at index position 0, making it the new first row group in the table.
Note
The xref:System.Windows.Documents.TableRowGroupCollection collection uses standard zero-based indexing.
[!code-csharpTableSnippets2#_Table_RowGroups_Insert] [!code-vbTableSnippets2#_Table_RowGroups_Insert]
The following example adds several rows to a particular xref:System.Windows.Documents.TableRowGroup (specified by index) in the table.
[!code-csharpTableSnippets2#_Table_RowGroups_AddRows] [!code-vbTableSnippets2#_Table_RowGroups_AddRows]
The following example accesses some arbitrary properties on rows in the first row group in the table.
[!code-csharpTableSnippets2#_Table_RowGroups_ManipRows] [!code-vbTableSnippets2#_Table_RowGroups_ManipRows]
The following example adds several cells to a particular xref:System.Windows.Documents.TableRow (specified by index) in the table.
[!code-csharpTableSnippets2#_Table_RowGroups_AddCells] [!code-vbTableSnippets2#_Table_RowGroups_AddCells]
The following example access some arbitrary methods and properties on cells in the first row in the first row group.
[!code-csharpTableSnippets2#_Table_RowGroups_ManipCells] [!code-vbTableSnippets2#_Table_RowGroups_ManipCells]
The following example returns the number of xref:System.Windows.Documents.TableRowGroup elements hosted by the table.
[!code-csharpTableSnippets2#_Table_RowGroups_Count] [!code-vbTableSnippets2#_Table_RowGroups_Count]
The following example removes a particular row group by reference.
[!code-csharpTableSnippets2#_Table_RowGroups_DelRef] [!code-vbTableSnippets2#_Table_RowGroups_DelRef]
The following example removes a particular row group by index.
[!code-csharpTableSnippets2#_Table_RowGroups_DelIndex] [!code-vbTableSnippets2#_Table_RowGroups_DelIndex]
The following example removes all row groups from the table's row groups collection.
[!code-csharpTableSnippets2#_Table_RowGroups_Clear] [!code-vbTableSnippets2#_Table_RowGroups_Clear]