Class GridBoundColumnsCollection
Represents a collection of GridBoundColumn objects in the GridDataBoundGrid control.
Inheritance
Implements
Namespace: Syncfusion.Windows.Forms.Grid
Assembly: Syncfusion.Grid.Windows.dll
Syntax
public class GridBoundColumnsCollection : BaseCollection, IList, ICollection, IEnumerable, ICloneable
Remarks
On the GridDataBoundGrid you access the GridBoundColumnsCollection through the GridBoundColumns property.
The GridBoundColumnsCollection uses standard Add(GridBoundColumn) and Remove(GridBoundColumn) 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 GridBoundColumn object within the collection.
Constructors
GridBoundColumnsCollection(ICurrencyManagerSource)
Initializes a new empty GridBoundColumnsCollection.
Declaration
public GridBoundColumnsCollection(ICurrencyManagerSource table)
Parameters
Type | Name | Description |
---|---|---|
ICurrencyManagerSource | table | A reference to the GridModelDataBinder this collection belongs to. |
Properties
Item[PropertyDescriptor]
Gets a specified GridBoundColumn in the GridBoundColumnsCollection.
Declaration
public GridBoundColumn this[PropertyDescriptor propDesc] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.ComponentModel.PropertyDescriptor | propDesc |
Property Value
Type |
---|
GridBoundColumn |
Item[Int32]
Gets a specified GridBoundColumn in the GridBoundColumnsCollection.
Declaration
public GridBoundColumn this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type |
---|
GridBoundColumn |
Item[String]
Gets a specified GridBoundColumn in the GridBoundColumnsCollection.
Declaration
public GridBoundColumn this[string columnName] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | columnName |
Property Value
Type |
---|
GridBoundColumn |
List
Gets the list items.
Declaration
protected override ArrayList List { get; }
Property Value
Type |
---|
System.Collections.ArrayList |
Owner
Gets the owner that also provides a reference to a CurrencyManager.
Declaration
public ICurrencyManagerSource Owner { get; }
Property Value
Type |
---|
ICurrencyManagerSource |
Methods
Add(GridBoundColumn)
Adds a GridBoundColumn to the collection.
Declaration
public virtual int Add(GridBoundColumn column)
Parameters
Type | Name | Description |
---|---|---|
GridBoundColumn | column | The GridBoundColumn to add. |
Returns
Type | Description |
---|---|
System.Int32 | The index of the new GridBoundColumn object. |
Examples
This example shows how to add a column to the grid.
// Creates a column collection to be added to the grid.
GridBoundColumnsCollection myColumn = (GridBoundColumnsCollection)this.gridDataBoundGrid1.Binder.InternalColumns.Clone();
// Creates the column to be added.
GridBoundColumn Column1 = new GridBoundColumn();
Column1.HeaderText = "NewColumn";
// Adds the created column to the collection.
myColumn.Add(Column1);
// Binds the created column collections to the grid bound columns.
this.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn;
' Creates a column to be added to the collection.
Dim myColumn1 As GridBoundColumnsCollection = CType(Me.gridDataBoundGrid1.Binder.InternalColumns.Clone(), GridBoundColumnsCollection)
Dim Column1 As New GridBoundColumn()
Column1.HeaderText = "NewColumn"
myColumn1.Add(Column1)
' Binds the created column to the grid bound columns.
Me.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn1
AddRange(GridBoundColumn[])
Adds an array of GridBoundColumn objects to the collection.
Declaration
public void AddRange(GridBoundColumn[] columns)
Parameters
Type | Name | Description |
---|---|---|
GridBoundColumn[] | columns | An array of DataGridColumnStyle objects to add to the collection. |
Examples
This example shows how to add an array of GridBoundColumns to the grid.
// Creates a column collection to be added to the grid.
GridBoundColumnsCollection myColumn = (GridBoundColumnsCollection)this.gridDataBoundGrid1.Binder.InternalColumns.Clone();
// Declares the range of columns to be added.
GridBoundColumn[] Column1 = new GridBoundColumn[5];
// Initializes each instance of the GridBoundColumns.
for (int i = 0; i<Column1.Length; i++)
Column1[i] = new GridBoundColumn();
Column1[0].HeaderText = "NewColumn 1";
Column1[1].HeaderText = "NewColumn 2";
Column1[2].HeaderText = "NewColumn 3";
Column1[3].HeaderText = "NewColumn 4";
Column1[4].HeaderText = "NewColumn 5";
// Binds the created column collections to the grid bound columns.
myColumn.AddRange(Column1);
this.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn;
' Creates a column collection to be added to the grid.
Dim myColumn As GridBoundColumnsCollection = CType(Me.gridDataBoundGrid1.Binder.InternalColumns.Clone(), GridBoundColumnsCollection)
' Declares the range of columns to be added.
Dim Column1(4) As GridBoundColumn
' Initializes each instance of the GridBoundColumns.
For i As Integer = 0 To Column1.Length - 1
Column1(i) = New GridBoundColumn()
Next i
Column1(0).HeaderText = "NewColumn 1"
Column1(1).HeaderText = "NewColumn 2"
Column1(2).HeaderText = "NewColumn 3"
Column1(3).HeaderText = "NewColumn 4"
Column1(4).HeaderText = "NewColumn 5"
' Binds the created column collections to the grid bound columns.
myColumn.AddRange(Column1)
Me.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn
Clear()
Clears the collection of GridBoundColumn objects.
Declaration
public void Clear()
Clone()
Creates a new GridBoundColumnsCollection and creates copies of all members in this collection.
Declaration
public virtual object Clone()
Returns
Type | Description |
---|---|
System.Object | A GridBoundColumnsCollection object. |
Contains(GridBoundColumn)
Gets a value indicating whether the GridBoundColumnsCollection contains a specific GridBoundColumn.
Declaration
public bool Contains(GridBoundColumn column)
Parameters
Type | Name | Description |
---|---|---|
GridBoundColumn | column | The GridBoundColumn to find. |
Returns
Type | Description |
---|---|
System.Boolean | True if the collection contains the GridBoundColumn; otherwise, False. |
Contains(PropertyDescriptor)
Gets a value indicating whether the GridBoundColumnsCollection contains a specific GridBoundColumn associated with the specified PropertyDescriptor.
Declaration
public bool Contains(PropertyDescriptor propDesc)
Parameters
Type | Name | Description |
---|---|---|
System.ComponentModel.PropertyDescriptor | propDesc | The System.ComponentModel.PropertyDescriptor associated with the desired GridBoundColumn. |
Returns
Type | Description |
---|---|
System.Boolean | True if the collection contains the GridBoundColumn; otherwise, False. |
Contains(String)
Gets a value indicating whether the GridBoundColumnsCollection contains a specific GridBoundColumn with a specific name.
Declaration
public bool Contains(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The MappingName of the desired GridBoundColumn. |
Returns
Type | Description |
---|---|
System.Boolean | True if the collection contains the GridBoundColumn; otherwise, False. |
CopyTo(GridBoundColumn[], Int32)
Copies the values to a one-dimensional System.Array instance at the specified index.
Declaration
public void CopyTo(GridBoundColumn[] array, int index)
Parameters
Type | Name | Description |
---|---|---|
GridBoundColumn[] | array | The one-dimensional System.Array that is the destination of the values copied from the GridCellModelCollection. |
System.Int32 | index | The index in the array where copying begins. |
CreateBoundColumn(PropertyDescriptor)
Creates a new item for this collection. Override this method if you want to support derived column types. See BoundColumnsCollectionType for a sample.
Declaration
public virtual GridBoundColumn CreateBoundColumn(PropertyDescriptor pd)
Parameters
Type | Name | Description |
---|---|---|
System.ComponentModel.PropertyDescriptor | pd | The property descriptor with information about the column. |
Returns
Type | Description |
---|---|
GridBoundColumn | A GridBoundColumn or derived class object. |
IndexOf(GridBoundColumn)
Gets the index of a specified GridBoundColumn.
Declaration
public int IndexOf(GridBoundColumn element)
Parameters
Type | Name | Description |
---|---|---|
GridBoundColumn | element | The GridBoundColumn to find. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index of the GridBoundColumn within the GridBoundColumnsCollection or -1 if no corresponding GridBoundColumn exists. |
Examples
This example shows how to add the column in the grid at the specified index.
// Creates a column collection to be added to the grid.
GridBoundColumnsCollection myColumn = (GridBoundColumnsCollection)this.gridDataBoundGrid1.Binder.InternalColumns.Clone();
// Creates the column to be added.
GridBoundColumn Column1 = new GridBoundColumn();
Column1.HeaderText = "NewColumn";
// Inserts the created column to the collection at the specified index of the grid. Here "3" is the column index.
myColumn.Insert(3, Column1);
// Binds the created column collections to the grid bound columns.
this.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn;
' Creates a column collection to be added to the grid.
Dim myColumn As GridBoundColumnsCollection = CType(Me.gridDataBoundGrid1.Binder.InternalColumns.Clone(), GridBoundColumnsCollection)
' Creates the column to be added.
Dim Column1 As New GridBoundColumn()
Column1.HeaderText = "NewColumn"
' Inserts the created column to the collection at the specified index of the grid. Here "3" is the column index.
myColumn.Insert(3, Column1)
' Binds the created column collections to the grid bound columns.
Me.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn
Insert(Int32, GridBoundColumn)
Inserts a column at the specified index.
Declaration
public void Insert(int index, GridBoundColumn column)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index. |
GridBoundColumn | column | The column. |
OnCollectionChanged(CollectionChangeEventArgs)
Raises a CollectionChanged event.
Declaration
protected virtual void OnCollectionChanged(CollectionChangeEventArgs ccevent)
Parameters
Type | Name | Description |
---|---|---|
System.ComponentModel.CollectionChangeEventArgs | ccevent | The System.ComponentModel.CollectionChangeEventArgsthat contains event data. |
Remove(GridBoundColumn)
Removes the specified GridBoundColumn from the GridBoundColumnsCollection.
Declaration
public void Remove(GridBoundColumn column)
Parameters
Type | Name | Description |
---|---|---|
GridBoundColumn | column | The GridBoundColumn to remove. |
Examples
This example show how to remove the column from the grid with the specified mapping name of the GridBoundColumn.
// Removes the column using GridBoundColumn mapping name.
this.gridDataBoundGrid1.Binder.InternalColumns.Remove(Column1);
' Removes the column using GridBoundColumn mapping name.
Me.gridDataBoundGrid1.Binder.InternalColumns.Remove(Column1)
RemoveAt(Int32)
Removes the GridBoundColumn with the specified index from the GridBoundColumnsCollection.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the GridBoundColumn. |
Examples
This example show to remove the column from the grid with the given column index.
// Removes column at the given index in the grid. Here "3" is the column index.
this.gridDataBoundGrid1.Binder.InternalColumns.RemoveAt(3);
' Removes column at the given index in the grid. Here "3" is the column index.
Me.gridDataBoundGrid1.Binder.InternalColumns.RemoveAt(3)
ResetPropertyDescriptors()
Resets all PropertyDescriptor for all GridBoundColumn objects in the collection.
Declaration
public void ResetPropertyDescriptors()
Events
CollectionChanged
Occurs when members in this collection have been added or removed.
Declaration
public event CollectionChangeEventHandler CollectionChanged
Event Type
Type |
---|
System.ComponentModel.CollectionChangeEventHandler |
Explicit Interface Implementations
ICollection.CopyTo(Array, Int32)
Declaration
void ICollection.CopyTo(Array array, int index)
Parameters
Type | Name | Description |
---|---|---|
System.Array | array | |
System.Int32 | index |
ICollection.Count
Gets the number of elements contained in the System.Collections.ICollection.
Declaration
int ICollection.Count { get; }
Returns
Type |
---|
System.Int32 |
ICollection.IsSynchronized
Gets a value indicating whether access to the System.Collections.ICollection is synchronized (thread safe).
Declaration
bool ICollection.IsSynchronized { get; }
Returns
Type |
---|
System.Boolean |
ICollection.SyncRoot
Gets an object that can be used to synchronize access to the System.Collections.ICollection.
Declaration
object ICollection.SyncRoot { get; }
Returns
Type |
---|
System.Object |
IEnumerable.GetEnumerator()
Returns an enumerator that iterates through a collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | An System.Collections.IEnumerator object that can be used to iterate through the collection. |
IList.Add(Object)
Used to add value to the list.
Declaration
int IList.Add(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The value to be added. |
Returns
Type | Description |
---|---|
System.Int32 | Returns the GridBoundColumn |
IList.Clear()
Used to cleat the collection.
Declaration
void IList.Clear()
IList.Contains(Object)
Determine whether the element is in the collection.
Declaration
bool IList.Contains(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The System.Object to locate in the System.Collections.ArrayList. The value can be null |
Returns
Type | Description |
---|---|
System.Boolean | rue if item is found in the System.Collections.ArrayList; otherwise, false. |
IList.get_Item(Int32)
Declaration
object IList.get_Item(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Returns
Type |
---|
System.Object |
IList.IndexOf(Object)
Searches for the specified System.Object and returns the zero-based index of the first occurrence within the entire System.Collections.ArrayList.
Declaration
int IList.IndexOf(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The System.Object to locate in the System.Collections.ArrayList. The value can be null. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index of the first occurrence of value within the entire System.Collections.ArrayList,if found; otherwise, -1. |
IList.Insert(Int32, Object)
Inserts a column at the specified index.
Declaration
void IList.Insert(int index, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index. |
System.Object | value | The column. |
IList.IsFixedSize
Gets a value indicating whether the System.Collections.IList has a fixed size.
Declaration
bool IList.IsFixedSize { get; }
Returns
Type |
---|
System.Boolean |
IList.IsReadOnly
Gets a value indicating whether the System.Collections.IList is read-only.
Declaration
bool IList.IsReadOnly { get; }
Returns
Type |
---|
System.Boolean |
IList.Item[Int32]
Gets or sets the element at the specified index.
Declaration
object IList.this[] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the element to get or set. |
Returns
Type | Description |
---|---|
System.Object | The element at the specified index. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | index is not a valid index in the System.Collections.IList. |
IList.Remove(Object)
Removes the specified GridBoundColumn from the GridBoundColumnsCollection.
Declaration
void IList.Remove(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The GridBoundColumn to remove. |
IList.RemoveAt(Int32)
Removes the GridBoundColumn with the specified index from the GridBoundColumnsCollection.
Declaration
void IList.RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the GridBoundColumn. |
IList.set_Item(Int32, Object)
Declaration
void IList.set_Item(int index, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | |
System.Object | value |