alexa
menu

WinForms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download

    Show / Hide Table of Contents

    Class GridBoundColumnsCollection

    Represents a collection of GridBoundColumn objects in the GridDataBoundGrid control.

    Inheritance
    System.Object
    GridBoundColumnsCollection
    Implements
    System.Collections.IList
    System.Collections.ICollection
    System.Collections.IEnumerable
    System.ICloneable
    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

    Implements

    System.Collections.IList
    System.Collections.ICollection
    System.Collections.IEnumerable
    System.ICloneable
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved