GridColumnStylesCollection Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
[<System.ComponentModel.ListBindable(false)>]
type GridColumnStylesCollection = class
inherit BaseCollection
interface IList
interface ICollection
interface IEnumerable
Public Class GridColumnStylesCollection
Inherits BaseCollection
Implements IList
- Inheritance
- Attributes
- Implements
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
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.
Count |
Gets the total number of elements in the collection. (Inherited from BaseCollection) |
Is |
Gets a value indicating whether the collection is read-only. (Inherited from BaseCollection) |
Is |
Gets a value indicating whether access to the ICollection is synchronized. (Inherited from BaseCollection) |
Item[Int32] |
Gets the DataGridColumnStyle at a specified index. |
Item[Property |
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. |
Sync |
Gets an object that can be used to synchronize access to the BaseCollection. (Inherited from BaseCollection) |
Add(Data |
Adds a column style to the collection. |
Add |
Adds an array of column style objects to the collection. |
Clear() |
Clears the collection of DataGridColumnStyle objects. |
Contains(Data |
Gets a value indicating whether the GridColumnStylesCollection contains the specified DataGridColumnStyle. |
Contains(Property |
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. |
Copy |
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) |
Create |
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) |
Get |
Gets the object that enables iterating through the members of the collection. (Inherited from BaseCollection) |
Get |
Serves as the default hash function. (Inherited from Object) |
Get |
Obsolete.
Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject) |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Index |
Gets the index of a specified DataGridColumnStyle. |
Initialize |
Obsolete.
Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject) |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
Memberwise |
Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject) |
On |
Raises the CollectionChanged event. |
Remove(Data |
Removes the specified DataGridColumnStyle from the GridColumnStylesCollection. |
Remove |
Removes the DataGridColumnStyle with the specified index from the GridColumnStylesCollection. |
Reset |
Sets the PropertyDescriptor for each column style in the collection to |
To |
Returns a string that represents the current object. (Inherited from Object) |
Collection |
Occurs when a change is made to the GridColumnStylesCollection. |
ICollection. |
Copies the collection to a compatible one-dimensional Array, starting at the specified index of the target array. |
ICollection. |
Gets the number of elements contained in the collection. |
ICollection. |
Gets a value indicating whether access to the GridColumnStylesCollection is synchronized (thread safe). |
ICollection. |
Gets an object that can be used to synchronize access to the GridColumnStylesCollection. |
IEnumerable. |
Returns an enumerator for the collection. |
IList. |
Adds an object to the collection. |
IList. |
Clears the collection of DataGridColumnStyle objects. |
IList. |
Determines whether an element is in the collection. |
IList. |
Returns the zero-based index of the first occurrence of the specified object in the collection. |
IList. |
This method is not supported by this control. |
IList. |
Gets a value indicating whether the collection has a fixed size. |
IList. |
Gets a value indicating whether the collection is read-only. |
IList. |
Gets the element at the specified index. |
IList. |
Removes the specified DataGridColumnStyle from the GridColumnStylesCollection. |
IList. |
Removes the DataGridColumnStyle at the specified index from the GridColumnStylesCollection. |
Cast<TResult>(IEnumerable) |
Casts the elements of an IEnumerable to the specified type. |
Of |
Filters the elements of an IEnumerable based on a specified type. |
As |
Enables parallelization of a query. |
As |
Converts an IEnumerable to an IQueryable. |
Product | Versions |
---|---|
.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 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: