* Suggestion/warning fixes for US-1889327. * Updated H2s. * Minor content edit. * Review edits. * Minor edits. * Update dotnet-desktop-guide/framework/wpf/advanced/localization-attributes-and-comments.md Co-authored-by: Andy (Steve) De George <[email protected]>
4.7 KiB
title, ms.date, ms.custom, description, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | ms.custom | description | dev_langs | helpviewer_keywords | ms.assetid | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| How to: Manipulate a Table's Columns through the Columns Property | 03/30/2017 | devdivchpfy22 | Learn how to manipulate a Table's Columns through the Columns property. |
|
|
3f8884f4-7e1f-456b-be06-fbd3cf469bf3 |
How to: Manipulate a Table's Columns through the Columns Property
This example demonstrates some of the more common operations that can be performed on a table's columns through the xref:System.Windows.Documents.Table.Columns%2A property.
Create a new table
The following example creates a new table and then uses the xref:System.Windows.Documents.TableColumnCollection.Add%2A method to add columns to the table's xref:System.Windows.Documents.Table.Columns%2A collection.
[!code-csharpTableSnippets2#_Table_Columns_Add] [!code-vbTableSnippets2#_Table_Columns_Add]
Insert a new TableColumn
The following example inserts a new xref:System.Windows.Documents.TableColumn. The new column is inserted at index position 0, making it the new first column in the table.
Note
The xref:System.Windows.Documents.TableColumnCollection collection uses standard zero-based indexing.
[!code-csharpTableSnippets2#_Table_Columns_Insert] [!code-vbTableSnippets2#_Table_Columns_Insert]
Access properties in the TableColumnCollection
The following example accesses some arbitrary properties on columns in the xref:System.Windows.Documents.TableColumnCollection collection, referring to particular columns by index.
[!code-csharpTableSnippets2#_Table_Columns_Manip] [!code-vbTableSnippets2#_Table_Columns_Manip]
Get the number of columns in a table
The following example gets the number of columns currently hosted by the table.
[!code-csharpTableSnippets2#_Table_Columns_Count] [!code-vbTableSnippets2#_Table_Columns_Count]
Remove a column by reference
The following example removes a particular column by reference.
[!code-csharpTableSnippets2#_Table_Columns_DelRef] [!code-vbTableSnippets2#_Table_Columns_DelRef]
Remove a column by index
The following example removes a particular column by index.
[!code-csharpTableSnippets2#_Table_Columns_DelIndex] [!code-vbTableSnippets2#_Table_Columns_DelIndex]
Remove all the columns
The following example removes all columns from the table's columns collection.
[!code-csharpTableSnippets2#_Table_Columns_Clear] [!code-vbTableSnippets2#_Table_Columns_Clear]