GridColumnStylesCollection GridColumnStylesCollection GridColumnStylesCollection GridColumnStylesCollection Class

Definition

Represents a collection of DataGridColumnStyle objects in the DataGrid control.

public ref class GridColumnStylesCollection : System::Windows::Forms::BaseCollection, System::Collections::IList
[System.ComponentModel.ListBindable(false)]
public class GridColumnStylesCollection : System.Windows.Forms.BaseCollection, System.Collections.IList
type GridColumnStylesCollection = class
    inherit BaseCollection
    interface IList
    interface ICollection
    interface IEnumerable
Public Class GridColumnStylesCollection
Inherits BaseCollection
Implements IList
Inheritance
GridColumnStylesCollectionGridColumnStylesCollectionGridColumnStylesCollectionGridColumnStylesCollection
Attributes
Implements

Examples

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 );

      }

   }
}

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);
      }
   }
}
Private Sub PrintColumnInformation(grid as DataGrid)
   Console.WriteLine("Count: " & grid.TableStyles.Count)
   Dim myTableStyle As DataGridTableStyle
   Dim myColumns As GridColumnStylesCollection
   Dim dgCol As DataGridColumnStyle
   For Each myTableStyle in grid.TableStyles
      myColumns = myTableStyle.GridColumnStyles
   
      ' Iterate through the collection and print each 
      ' object's type and width.
      For Each dgCol in myColumns
         Console.WriteLine(dgCol.MappingName)
         Console.WriteLine(dgCol.GetType.ToString())
         Console.WriteLine(dgCol.Width)
      Next
   Next
End Sub

Remarks

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.

Properties

Count Count Count Count

Gets the total number of elements in the collection.

(Inherited from BaseCollection)
IsReadOnly IsReadOnly IsReadOnly IsReadOnly

Gets a value indicating whether the collection is read-only.

(Inherited from BaseCollection)
IsSynchronized IsSynchronized IsSynchronized IsSynchronized

Gets a value indicating whether access to the ICollection is synchronized.

(Inherited from BaseCollection)
Item[Int32] Item[Int32] Item[Int32] Item[Int32]

Gets the DataGridColumnStyle at a specified index.

Item[PropertyDescriptor] Item[PropertyDescriptor] Item[PropertyDescriptor] Item[PropertyDescriptor]

Gets the DataGridColumnStyle associated with the specified PropertyDescriptor.

Item[String] Item[String] Item[String] Item[String]

Gets the DataGridColumnStyle with the specified name.

List List List List

Gets the list of items in the collection.

SyncRoot SyncRoot SyncRoot SyncRoot

Gets an object that can be used to synchronize access to the BaseCollection.

(Inherited from BaseCollection)

Methods

Add(DataGridColumnStyle) Add(DataGridColumnStyle) Add(DataGridColumnStyle) Add(DataGridColumnStyle)

Adds a column style to the collection.

AddRange(DataGridColumnStyle[]) AddRange(DataGridColumnStyle[]) AddRange(DataGridColumnStyle[]) AddRange(DataGridColumnStyle[])

Adds an array of column style objects to the collection.

Clear() Clear() Clear() Clear()

Clears the collection of DataGridColumnStyle objects.

Contains(DataGridColumnStyle) Contains(DataGridColumnStyle) Contains(DataGridColumnStyle) Contains(DataGridColumnStyle)

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

Contains(PropertyDescriptor) Contains(PropertyDescriptor) Contains(PropertyDescriptor) Contains(PropertyDescriptor)

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

Contains(String) Contains(String) Contains(String) Contains(String)

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

CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) 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) CreateObjRef(Type) CreateObjRef(Type) 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) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

Gets the object that enables iterating through the members of the collection.

(Inherited from BaseCollection)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
IndexOf(DataGridColumnStyle) IndexOf(DataGridColumnStyle) IndexOf(DataGridColumnStyle) IndexOf(DataGridColumnStyle)

Gets the index of a specified DataGridColumnStyle.

InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
OnCollectionChanged(CollectionChangeEventArgs) OnCollectionChanged(CollectionChangeEventArgs) OnCollectionChanged(CollectionChangeEventArgs) OnCollectionChanged(CollectionChangeEventArgs)

Raises the CollectionChanged event.

Remove(DataGridColumnStyle) Remove(DataGridColumnStyle) Remove(DataGridColumnStyle) Remove(DataGridColumnStyle)

Removes the specified DataGridColumnStyle from the GridColumnStylesCollection.

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

Removes the DataGridColumnStyle with the specified index from the GridColumnStylesCollection.

ResetPropertyDescriptors() ResetPropertyDescriptors() ResetPropertyDescriptors() ResetPropertyDescriptors()

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

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Events

CollectionChanged CollectionChanged CollectionChanged CollectionChanged

Occurs when a change is made to the GridColumnStylesCollection.

Explicit Interface Implementations

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

Copies the collection to a compatible one-dimensional Array, starting at the specified index of the target array.

ICollection.Count ICollection.Count ICollection.Count ICollection.Count

Gets the number of elements contained in the collection.

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

Gets a value indicating whether access to the GridColumnStylesCollection is synchronized (thread safe).

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

Gets an object that can be used to synchronize access to the GridColumnStylesCollection.

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

Returns an enumerator for the collection.

IList.Add(Object) IList.Add(Object) IList.Add(Object) IList.Add(Object)

Adds an object to the collection.

IList.Clear() IList.Clear() IList.Clear() IList.Clear()

Clears the collection of DataGridColumnStyle objects.

IList.Contains(Object) IList.Contains(Object) IList.Contains(Object) IList.Contains(Object)

Determines whether an element is in the collection.

IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object)

Returns the zero-based index of the first occurrence of the specified object in the collection.

IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object)

This method is not supported by this control.

IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize

Gets a value indicating whether the collection has a fixed size.

IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly

Gets a value indicating whether the collection is read-only.

IList.Item[Int32] IList.Item[Int32] IList.Item[Int32] IList.Item[Int32]

Gets the element at the specified index.

IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) IList.Remove(Object)

Removes the specified DataGridColumnStyle from the GridColumnStylesCollection.

IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32)

Removes the DataGridColumnStyle at the specified index from the GridColumnStylesCollection.

Extension Methods

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Applies to

See also