GridColumnStylesCollection Class
TOC
Collapse the table of content
Expand the table of content

GridColumnStylesCollection Class

 

Represents a collection of DataGridColumnStyle objects in the System.Windows.Forms.DataGrid control.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

System.Object
  System.MarshalByRefObject
    System.Windows.Forms.BaseCollection
      System.Windows.Forms.GridColumnStylesCollection

[ListBindableAttribute(false)]
public class GridColumnStylesCollection : BaseCollection, IList, 
	ICollection, IEnumerable

NameDescription
System_CAPS_pubpropertyCount

Gets the total number of elements in the collection.(Inherited from BaseCollection.)

System_CAPS_pubpropertyIsReadOnly

Gets a value indicating whether the collection is read-only.(Inherited from BaseCollection.)

System_CAPS_pubpropertyIsSynchronized

Gets a value indicating whether access to the ICollection is synchronized.(Inherited from BaseCollection.)

System_CAPS_pubpropertyItem[Int32]

Gets the DataGridColumnStyle at a specified index.

System_CAPS_pubpropertyItem[PropertyDescriptor]

Gets the DataGridColumnStyle associated with the specified PropertyDescriptor.

System_CAPS_pubpropertyItem[String]

Gets the DataGridColumnStyle with the specified name.

System_CAPS_protpropertyList

Gets the list of items in the collection.(Overrides BaseCollection.List.)

System_CAPS_pubpropertySyncRoot

Gets an object that can be used to synchronize access to the BaseCollection.(Inherited from BaseCollection.)

NameDescription
System_CAPS_pubmethodAdd(DataGridColumnStyle)

Adds a column style to the collection.

System_CAPS_pubmethodAddRange(DataGridColumnStyle[])

Adds an array of column style objects to the collection.

System_CAPS_pubmethodClear()

Clears the collection of DataGridColumnStyle objects.

System_CAPS_pubmethodContains(DataGridColumnStyle)

Gets a value indicating whether the GridColumnStylesCollection contains the specified DataGridColumnStyle.

System_CAPS_pubmethodContains(PropertyDescriptor)

Gets a value indicating whether the GridColumnStylesCollection contains a DataGridColumnStyle associated with the specified PropertyDescriptor.

System_CAPS_pubmethodContains(String)

Gets a value indicating whether the GridColumnStylesCollection contains the DataGridColumnStyle with the specified name.

System_CAPS_pubmethodCopyTo(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.)

System_CAPS_pubmethodCreateObjRef(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.)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetEnumerator()

Gets the object that enables iterating through the members of the collection.(Inherited from BaseCollection.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodIndexOf(DataGridColumnStyle)

Gets the index of a specified DataGridColumnStyle.

System_CAPS_pubmethodInitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.(Inherited from MarshalByRefObject.)

System_CAPS_protmethodOnCollectionChanged(CollectionChangeEventArgs)

Raises the CollectionChanged event.

System_CAPS_pubmethodRemove(DataGridColumnStyle)

Removes the specified DataGridColumnStyle from the GridColumnStylesCollection.

System_CAPS_pubmethodRemoveAt(Int32)

Removes the DataGridColumnStyle with the specified index from the GridColumnStylesCollection.

System_CAPS_pubmethodResetPropertyDescriptors()

Sets the PropertyDescriptor for each column style in the collection to null.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubeventCollectionChanged

Occurs when a change is made to the GridColumnStylesCollection.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodICollection.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.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIEnumerable.GetEnumerator()

This API supports the product infrastructure and is not intended to be used directly from your code. Returns an enumerator for the collection.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.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.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.Clear()

This API supports the product infrastructure and is not intended to be used directly from your code. Clears the collection of DataGridColumnStyle objects.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.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.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.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.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.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.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.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.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.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.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.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.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.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).

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.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.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIList.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.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIList.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.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIList.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.

NameDescription
System_CAPS_pubmethodAsParallel()

Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)

System_CAPS_pubmethodAsQueryable()

Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)

System_CAPS_pubmethodCast<TResult>()

Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)

System_CAPS_pubmethodOfType<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.

System_CAPS_cautionCaution

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.

private void PrintColumnInformation(DataGrid grid){
   Console.WriteLine("Count: " + grid.TableStyles.Count);
   GridColumnStylesCollection myColumns;   
   foreach(DataGridTableStyle myTableStyle in grid.TableStyles){

      myColumns = myTableStyle.GridColumnStyles;

      /* Iterate through the collection and print each 
      object's type and width. */
      foreach (DataGridColumnStyle dgCol in myColumns){
         Console.WriteLine(dgCol.MappingName);
         Console.WriteLine(dgCol.GetType().ToString());
         Console.WriteLine(dgCol.Width);
      }
   }
}

.NET Framework
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.

Return to top
Show:
© 2016 Microsoft