GridColumnStylesCollection.AddRange(DataGridColumnStyle[]) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将列样式对象数组添加到集合中。
public:
void AddRange(cli::array <System::Windows::Forms::DataGridColumnStyle ^> ^ columns);
public void AddRange (System.Windows.Forms.DataGridColumnStyle[] columns);
member this.AddRange : System.Windows.Forms.DataGridColumnStyle[] -> unit
Public Sub AddRange (columns As DataGridColumnStyle())
参数
- columns
- DataGridColumnStyle[]
要添加到集合中的 DataGridColumnStyle 对象的数组。
示例
下面的代码示例创建一个对象数组 DataGridColumnStyle ,并使用 AddRange 该方法将数组添加到该 GridColumnStylesCollection数组。
void AddStyleRange()
{
// Create two DataGridColumnStyle objects.
DataGridColumnStyle^ col1 = gcnew DataGridTextBoxColumn;
col1->MappingName = "FirstName";
DataGridColumnStyle^ col2 = gcnew DataGridBoolColumn;
col2->MappingName = "Current";
// Create an array and use AddRange to add to collection.
array<DataGridColumnStyle^>^cols = {col1,col2};
dataGrid1->TableStyles[ 0 ]->GridColumnStyles->AddRange( cols );
}
private void AddStyleRange()
{
// Create two DataGridColumnStyle objects.
DataGridColumnStyle col1 = new DataGridTextBoxColumn();
col1.MappingName = "FirstName";
DataGridColumnStyle col2 = new DataGridBoolColumn();
col2.MappingName = "Current";
// Create an array and use AddRange to add to collection.
DataGridColumnStyle[] cols = new DataGridColumnStyle[2] {col1, col2};
dataGrid1.TableStyles[0].GridColumnStyles.AddRange(cols);
}
Private Sub AddStyleRange()
' Create two DataGridColumnStyle objects.
Dim col1 As New DataGridTextBoxColumn()
col1.MappingName = "FirstName"
Dim col2 As New DataGridBoolColumn()
col2.MappingName = "Current"
' Create an array and use AddRange to add to collection.
Dim cols() As DataGridColumnStyle = {col1, col2}
dataGrid1.TableStyles(0).GridColumnStyles.AddRange(cols)
End Sub