New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial

The collection of columns of RadGrid or its tables. Accessible through Columns property of RadGrid and GridTableView (MasterTableView) classes.

Its items are of the available Grid column types.

Definition

Namespace:Telerik.Web.UI

Assembly:Telerik.Web.UI.dll

Syntax:

C#
public class GridColumnCollection : IList, ICollection, IEnumerable, IStateManager

Inheritance: objectGridColumnCollection

Implements: ICollectionIEnumerableIListIStateManager

Inherited Members object.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()...

Example:

csharp
GridBoundColumn boundColumn;
boundColumn = new GridBoundColumn();
boundColumn.DataField = "CustomerID";
boundColumn.HeaderText = "CustomerID";
RadGrid1.MasterTableView.Columns.Add(boundColumn);
boundColumn = new GridBoundColumn();
boundColumn.DataField = "ContactName";
boundColumn.HeaderText = "Contact Name";
RadGrid1.MasterTableView.Columns.Add(boundColumn);
RadGrid1.MasterTableView.Columns.Add( new GridExpandColumn() );
csharp
Dim boundColumn As GridBoundColumn
boundColumn = New GridBoundColumn()
boundColumn.DataField = "CustomerID"
boundColumn.HeaderText = "CustomerID"
RadGrid1.MasterTableView.Columns.Add(boundColumn)
boundColumn = New GridBoundColumn()
boundColumn.DataField = "ContactName"
boundColumn.HeaderText = "Contact Name"
RadGrid1.MasterTableView.Columns.Add(boundColumn)
RadGrid1.MasterTableView.Columns.Add(New GridExpandColumn())

Constructors

C#
public GridColumnCollection(GridTableView owner, ArrayList columns)
Parameters:ownerGridTableViewcolumnsArrayList
C#
public GridColumnCollection(GridTableView owner)
Parameters:ownerGridTableView

Properties

Gets the number of columns added programmatically or declaratively.

C#
[Browsable(false)]
public int Count { get; }

Implements: ICollection.Count

Note that this is not the actual number of column in a GridTableView. See also RenderColumns

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

C#
public bool IsFixedSize { get; }
Property Value:

true if the collection has a fixed size; otherwise, false.

Implements: IList.IsFixedSize

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

C#
[Browsable(false)]
public bool IsReadOnly { get; }
Property Value:

true if the collection is read-only; otherwise, false.

Implements: IList.IsReadOnly

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

C#
[Browsable(false)]
public bool IsSynchronized { get; }
Property Value:

true if access to the collection is synchronized (thread safe); otherwise, false.

Implements: ICollection.IsSynchronized

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

C#
[Browsable(false)]
public object SyncRoot { get; }
Property Value:

An object that can be used to synchronize access to the collection.

Implements: ICollection.SyncRoot

C#
public GridColumn this[int index] { get; }
Parameters:indexint

If the column/detail table structure is created after the control has been initialized (indicated by RadGrid.Init event ) the state of the columns/detail tables may have been lost. This happens when properties have been set to GridColumn/GridTableView instance before it has been added to the corresponding collection of Columns/DetailTables. Then a GridException is thrown with message: "Failed accessing GridColumn by index. Please verify that you have specified the structure of RadGrid correctly."

Methods

Adds a column object to the GridColumnCollection.

C#
public void Add(GridColumn column)
Parameters:columnGridColumn

The GridColumn object to add to the collection.

Adds an item to the collection.

C#
public int Add(object Val)
Parameters:ValobjectReturns:

int

The position into which the new element was inserted.

Implements: IList.Add(object)

Adds a column in the collection at the specified index.

C#
public void AddAt(int index, GridColumn column)
Parameters:indexint

The index where the column will be inserted.

columnGridColumn

The column that will be inserted.

Removes all column from the collection.

C#
public void Clear()

Implements: IList.Clear()

Determines whether the CridColumnCollection contains the value specified by the given GridColumn object.

C#
public bool Contains(object Val)
Parameters:Valobject

GridColumn object to locate in the GridColumnCollection.

Returns:

bool

true if the GridColumn is found in the GridColumnCollection; otherwise, false.

Implements: IList.Contains(object)

Copies the columns of the collection to an Array, starting at a particular Array index.

C#
public void CopyTo(Array array, int index)
Parameters:arrayArray

The one-dimensional Array that is the destination of the elements copied from ICollection. The Array must have zero-based indexing.

indexint

The zero-based index in array at which copying begins.

Exceptions: ArgumentNullException

array is null.

ArgumentOutOfRangeException

index is less than zero.

ArgumentException

array is multidimensional.-or- The number of elements in the source ICollection is greater than the available space from index to the end of the destination array.-or- The type of the source collection cannot be cast automatically to the type of the destination array.

Implements: ICollection.CopyTo(Array, int)

C#
protected virtual GridColumn CreateColumnFromTypeName(string columnTypeName)
Parameters:columnTypeNamestringReturns:

GridColumn

Gets all columns found bound to the DataField specified. Returns null is no column is bound to this DataField

C#
public GridColumn[] FindAllByDataField(string DataField)
Parameters:DataFieldstringReturns:

GridColumn[]

Gets the first column found bound to the DataField. Throws GridException if no column is bound to this DataField

C#
public GridColumn FindByDataField(string DataField)
Parameters:DataFieldstringReturns:

GridColumn

Gets the first column found bound to the DataField. Returns null is no column is bound to this DataField

C#
public GridColumn FindByDataFieldSafe(string DataField)
Parameters:DataFieldstringReturns:

GridColumn

Gets the first column with UniqueName found. Throws GridException if no column is found.

C#
public GridColumn FindByUniqueName(string UniqueName)
Parameters:UniqueNamestringReturns:

GridColumn

Gets the first column with UniqueName found. Returns null if no column is found.

C#
public GridColumn FindByUniqueNameSafe(string UniqueName)
Parameters:UniqueNamestringReturns:

GridColumn

Returns an enumerator that iterates through a collection.

C#
public IEnumerator GetEnumerator()
Returns:

IEnumerator

An IEnumerator object that can be used to iterate through the collection.

Implements: IEnumerable.GetEnumerator()

Determines the index of a specific column in the GridColumnCollection.

C#
public int IndexOf(GridColumn column)
Parameters:columnGridColumn

The GridColumn to locate in the GridColumnCollection.

Returns:

int

The index of value if found in the collection; otherwise, -1.

Determines the index of a specific column in the GridColumnCollection.

C#
public int IndexOf(object Val)
Parameters:Valobject

The object to locate in the GridColumnCollection.

Returns:

int

The index of value if found in the collection; otherwise, -1.

Implements: IList.IndexOf(object)

Inserts a column to the GridColumnCollectino at the specified index.

C#
public void Insert(int Index, object Val)
Parameters:Indexint

The zero-based index at which column should be inserted.

Valobject

The GridColumn to insert into the collection.

Implements: IList.Insert(int, object)

Removes the first occurrence of a column from the GridColumnCollection.

C#
public void Remove(GridColumn column)
Parameters:columnGridColumn

The column to remove from the collection.

Removes the first occurrence of an object from the GridColumnCollection.

C#
public void Remove(object Val)
Parameters:Valobject

The object to remove from the collection.

Implements: IList.Remove(object)

Removes the GridColumnCollection item at the specified index.

C#
public void RemoveAt(int index)
Parameters:indexint

The zero-based index of the item(column) to remove.

Implements: IList.RemoveAt(int)