GridColumnStylesCollection Class
Represents a collection of DataGridColumnStyle objects in the System.Windows.Forms::DataGrid control.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
System::MarshalByRefObject
System.Windows.Forms::BaseCollection
System.Windows.Forms::GridColumnStylesCollection
| Name | Description | |
|---|---|---|
![]() | Count | Gets the total number of elements in the collection.(Inherited from BaseCollection.) |
![]() | IsReadOnly | Gets a value indicating whether the collection is read-only.(Inherited from BaseCollection.) |
![]() | IsSynchronized | Gets a value indicating whether access to the ICollection is synchronized.(Inherited from BaseCollection.) |
![]() | Item[Int32] | Gets the DataGridColumnStyle at a specified index. |
![]() | Item[PropertyDescriptor^] | Gets the DataGridColumnStyle associated with the specified PropertyDescriptor. |
![]() | Item[String^] | Gets the DataGridColumnStyle with the specified name. |
![]() | List | Gets the list of items in the collection.(Overrides BaseCollection::List.) |
![]() | SyncRoot | Gets an object that can be used to synchronize access to the BaseCollection.(Inherited from BaseCollection.) |
| Name | Description | |
|---|---|---|
![]() | Add(DataGridColumnStyle^) | Adds a column style to the collection. |
![]() | AddRange(array<DataGridColumnStyle^>^) | Adds an array of column style objects to the collection. |
![]() | Clear() | Clears the collection of DataGridColumnStyle objects. |
![]() | Contains(DataGridColumnStyle^) | Gets a value indicating whether the GridColumnStylesCollection contains the specified DataGridColumnStyle. |
![]() | Contains(PropertyDescriptor^) | Gets a value indicating whether the GridColumnStylesCollection contains a DataGridColumnStyle associated with the specified PropertyDescriptor. |
![]() | Contains(String^) | Gets a value indicating whether the GridColumnStylesCollection contains the DataGridColumnStyle with the specified name. |
![]() | CopyTo(Array^, Int32) | Copies all the elements of the current one-dimensional Array to the specified one-dimensional Array starting at the specified destination Array index.(Inherited from BaseCollection.) |
![]() | CreateObjRef(Type^) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.) |
![]() | Equals(Object^) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Finalize() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) |
![]() | GetEnumerator() | Gets the object that enables iterating through the members of the collection.(Inherited from BaseCollection.) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetLifetimeService() | Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.) |
![]() | GetType() | |
![]() | IndexOf(DataGridColumnStyle^) | Gets the index of a specified DataGridColumnStyle. |
![]() | InitializeLifetimeService() | Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.) |
![]() | MemberwiseClone() | |
![]() | MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object.(Inherited from MarshalByRefObject.) |
![]() | OnCollectionChanged(CollectionChangeEventArgs^) | Raises the CollectionChanged event. |
![]() | Remove(DataGridColumnStyle^) | Removes the specified DataGridColumnStyle from the GridColumnStylesCollection. |
![]() | RemoveAt(Int32) | Removes the DataGridColumnStyle with the specified index from the GridColumnStylesCollection. |
![]() | ResetPropertyDescriptors() | Sets the PropertyDescriptor for each column style in the collection to null. |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() | CollectionChanged | Occurs when a change is made to the GridColumnStylesCollection. |
| Name | Description | |
|---|---|---|
![]() ![]() | ICollection::CopyTo(Array^, Int32) | This API supports the product infrastructure and is not intended to be used directly from your code. Copies the collection to a compatible one-dimensional Array, starting at the specified index of the target array. |
![]() ![]() | IEnumerable::GetEnumerator() | This API supports the product infrastructure and is not intended to be used directly from your code. Returns an enumerator for the collection. |
![]() ![]() | IList::Add(Object^) | This API supports the product infrastructure and is not intended to be used directly from your code. Adds an object to the collection. |
![]() ![]() | IList::Clear() | This API supports the product infrastructure and is not intended to be used directly from your code. Clears the collection of DataGridColumnStyle objects. |
![]() ![]() | IList::Contains(Object^) | This API supports the product infrastructure and is not intended to be used directly from your code. Determines whether an element is in the collection. |
![]() ![]() | IList::IndexOf(Object^) | This API supports the product infrastructure and is not intended to be used directly from your code. Returns the zero-based index of the first occurrence of the specified object in the collection. |
![]() ![]() | IList::Insert(Int32, Object^) | This API supports the product infrastructure and is not intended to be used directly from your code. This method is not supported by this control. |
![]() ![]() | IList::Remove(Object^) | This API supports the product infrastructure and is not intended to be used directly from your code. Removes the specified DataGridColumnStyle from the GridColumnStylesCollection. |
![]() ![]() | IList::RemoveAt(Int32) | This API supports the product infrastructure and is not intended to be used directly from your code. Removes the DataGridColumnStyle at the specified index from the GridColumnStylesCollection. |
![]() ![]() | ICollection::Count | This API supports the product infrastructure and is not intended to be used directly from your code. Gets the number of elements contained in the collection. |
![]() ![]() | ICollection::IsSynchronized | This API supports the product infrastructure and is not intended to be used directly from your code. Gets a value indicating whether access to the GridColumnStylesCollection is synchronized (thread safe). |
![]() ![]() | ICollection::SyncRoot | This API supports the product infrastructure and is not intended to be used directly from your code. Gets an object that can be used to synchronize access to the GridColumnStylesCollection. |
![]() ![]() | IList::IsFixedSize | This API supports the product infrastructure and is not intended to be used directly from your code. Gets a value indicating whether the collection has a fixed size. |
![]() ![]() | IList::IsReadOnly | This API supports the product infrastructure and is not intended to be used directly from your code. Gets a value indicating whether the collection is read-only. |
![]() ![]() | IList::Item[Int32] | This API supports the product infrastructure and is not intended to be used directly from your code. Gets the element at the specified index. |
| Name | Description | |
|---|---|---|
![]() | AsParallel() | Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.) |
![]() | AsQueryable() | Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.) |
![]() | Cast<TResult>() | Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.) |
![]() | OfType<TResult>() | Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.) |
On the DataGridTableStyle, you access the GridColumnStylesCollection through the GridColumnStyles property.
The GridColumnStylesCollection uses standard Add and Remove methods to manipulate the collection.
Use the Contains method to determine if a specific property value exists in the collection. Additionally, use the IndexOf method to determine the index of any DataGridColumnStyle object within the collection.
Caution |
|---|
Always create DataGridColumnStyle objects and add them to the GridColumnStylesCollection before adding DataGridTableStyle objects to the GridTableStylesCollection. When you add an empty DataGridTableStyle with a valid MappingName value to the collection, DataGridColumnStyle objects are automatically generated for you. Consequently, an exception will be thrown if you try to add new DataGridColumnStyle objects with duplicate MappingName values to the GridColumnStylesCollection. |
The following code example prints information about each DataGridColumnStyle in a GridColumnStylesCollection.
void PrintColumnInformation( DataGrid^ grid ) { Console::WriteLine( "Count: {0}", grid->TableStyles->Count ); GridColumnStylesCollection^ myColumns; DataGridTableStyle^ myTableStyle; for ( __int32 i = 0; i < grid->TableStyles->Count; i++ ) { myTableStyle = grid->TableStyles[ i ]; myColumns = myTableStyle->GridColumnStyles; /* Iterate through the collection and print each object's type and width. */ DataGridColumnStyle^ dgCol; for ( __int32 j = 0; j < myColumns->Count; j++ ) { dgCol = myColumns[ j ]; Console::WriteLine( dgCol->MappingName ); Console::WriteLine( dgCol->GetType()->ToString() ); Console::WriteLine( dgCol->Width ); } } }
Available since 1.1
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.








