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