GridView.Columns 属性

定义

获取为此 GridViewColumn 定义的 GridView 对象的集合。

public:
 property System::Windows::Controls::GridViewColumnCollection ^ Columns { System::Windows::Controls::GridViewColumnCollection ^ get(); };
public System.Windows.Controls.GridViewColumnCollection Columns { get; }
member this.Columns : System.Windows.Controls.GridViewColumnCollection
Public ReadOnly Property Columns As GridViewColumnCollection

属性值

GridViewColumnCollection

GridView 中列的集合。 默认值是 null

示例

以下示例演示如何使用Add属性上的Columns方法将列添加到GridViewColumn列中GridView

GridViewColumn gvc3 = new GridViewColumn();
gvc3.DisplayMemberBinding = new Binding("EmployeeNumber");
gvc3.Header = "Employee No.";
gvc3.Width = 100;
myGridView.Columns.Add(gvc3);
Dim gvc3 As New GridViewColumn()
gvc3.DisplayMemberBinding = New Binding("EmployeeNumber")
gvc3.Header = "Employee No."
gvc3.Width = 100
myGridView.Columns.Add(gvc3)

注解

通过此属性,可以使用继承自Collection<T>类的方法(例如InsertAdd,和Remove方法)修改为 a GridView定义的列。

XAML 属性元素用法

<object>  
  OneOrMoreGridViewColumns  
</object>  

XAML 值

OneOrMoreGridViewColumns
一个或多个 GridViewColumn 元素。

适用于