GridColumnStylesCollection.AddRange(DataGridColumnStyle[]) Method

Definition

Adds an array of column style objects to the collection.

C#
public void AddRange(System.Windows.Forms.DataGridColumnStyle[] columns);

Parameters

columns
DataGridColumnStyle[]

An array of DataGridColumnStyle objects to add to the collection.

Examples

The following code example creates an array of DataGridColumnStyle objects, and uses the AddRange method to add the array to the GridColumnStylesCollection.

C#
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);
}

Applies to

Produkt Verzie
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 10