Skip to main content
Version: 4.1

DataGridViewColumnCollection

Namespace: Wisej.Web

Assembly: Wisej.Framework (4.1.0.0)

Represents a collection of DataGridViewColumn objects in a DataGridView control.

public class DataGridViewColumnCollection : BaseCollection, IList, IList<DataGridViewColumn>, ICollection<DataGridViewColumn>, IEnumerable<DataGridViewColumn>

Constructors

Instance member DataGridViewColumnCollection(dataGrid)

Initializes a new instance of the DataGridViewColumnCollection class for the given DataGridView.

NameTypeDescription
dataGridDataGridViewThe DataGridView that created this collection.

Properties

Instance member Item(index)

DataGridViewColumn: Returns the column at the given index in the collection.

Throws:

Instance member Item(name)

DataGridViewColumn: Returns the column of the given name in the collection.

Throws:

Instance member List

IList: Returns the collection.

Methods

Instance member Add(column)

Adds the given DataGridViewColumn to the collection.

ParameterTypeDescription
columnDataGridViewColumnThe DataGridViewColumn to add.

Returns: Int32. The index of the column.

Throws:

Instance member Add(name)

Adds a DataGridViewTextBoxColumn with the given column name to the collection.

ParameterTypeDescription
nameStringThe name by which the column will be referred.

Returns: Int32. The index of the column.

Throws:

Instance member Add(name, valueType)

Adds a DataGridViewTextBoxColumn with the given column name and call value type to the collection.

ParameterTypeDescription
nameStringThe name by which the column will be referred.
valueTypeTypeThe Type of the values in the cells.

Returns: Int32. The index of the column.

Throws:

Instance member Add(name, caption)

Adds a DataGridViewTextBoxColumn with the given column name and column header text to the collection.

ParameterTypeDescription
nameStringThe name by which the column will be referred.
captionStringThe text for the column's header.

Returns: Int32. The index of the column.

Throws:

Instance member Add(name, caption, valueType)

Adds a DataGridViewTextBoxColumn with the given column name, column header text, and cell value type to the collection.

ParameterTypeDescription
nameStringThe name by which the column will be referred.
captionStringThe text for the column's header.
valueTypeTypeThe Type of the values in the cells.

Returns: Int32. The index of the column.

Throws:

Instance member AddRange(newColumns)

Adds a range of columns to the collection.

ParameterTypeDescription
newColumnsDataGridViewColumn[]An array of DataGridViewColumn objects to add.

Throws:

Instance member Clear()

Clears the collection.

Throws:

Instance member Clear(dispose)

Clears the collection and disposes the columns.

ParameterTypeDescription
disposeBoolean

Instance member Contains(column)

Determines whether the collection contains the given DataGridViewColumn.

ParameterTypeDescription
columnDataGridViewColumnThe DataGridViewColumn to look for.

Returns: Boolean. true if the given column is in the collection; otherwise, false.

Instance member Contains(name)

Determines whether the collection contains the given DataGridViewColumn.

ParameterTypeDescription
nameStringThe name of the column to look for.

Returns: Boolean. true if the given column is in the collection; otherwise, false.

Instance member CopyTo(array, index)

Copies the items from the collection to the given array.

ParameterTypeDescription
arrayDataGridViewColumn[]The destination DataGridViewColumn array.
indexInt32The index of the destination array at which to start copying.

Instance member GetColumnCount(includeFilter)

Returns the number of columns that match the includeFilter .

ParameterTypeDescription
includeFilterDataGridViewElementStatesA combination of the DataGridViewElementStates values for inclusion.

Returns: Int32. The number of columns that match the filter.

Throws:

Instance member GetColumnsWidth(includeFilter)

Returns the width, in pixels, required to display all of the columns that meet the includeFilter .

ParameterTypeDescription
includeFilterDataGridViewElementStatesA combination of the DataGridViewElementStates values for inclusion.

Returns: Int32. The width, in pixels, that is necessary to display all of the columns that match the filter.

Throws:

Instance member GetFirstColumn(includeFilter, excludeFilter)

Returns the first DataGridViewColumn in display order that matches the includeFilter and excludeFilter .

ParameterTypeDescription
includeFilter optionalDataGridViewElementStatesA combination of the DataGridViewElementStates values for inclusion.
excludeFilter optionalDataGridViewElementStatesA combination of the DataGridViewElementStates values for exclusion.

Returns: DataGridViewColumn. The first DataGridViewColumn in display order that matches the given filters, or null if no column is found.

Throws:

Instance member GetLastColumn(includeFilter, excludeFilter)

Returns the last DataGridViewColumn in display order that matches the includeFilter and excludeFilter .

ParameterTypeDescription
includeFilter optionalDataGridViewElementStatesA combination of the DataGridViewElementStates values for inclusion.
excludeFilter optionalDataGridViewElementStatesA combination of the DataGridViewElementStates values for exclusion.

Returns: DataGridViewColumn. The last displayed DataGridViewColumn in display order that matches the specified filters, or null if no column is found.

Throws:

Instance member GetNextColumn(startColumn, includeFilter, excludeFilter)

Returns the first DataGridViewColumn after the given column in display order that matches the includeFilter and excludeFilter .

ParameterTypeDescription
startColumnDataGridViewColumnThe column from which to start searching for the next column.
includeFilter optionalDataGridViewElementStatesA combination of the DataGridViewElementStates values for inclusion.
excludeFilter optionalDataGridViewElementStatesA combination of the DataGridViewElementStates values for exclusion.

Returns: DataGridViewColumn. The next DataGridViewColumn that matches the filters, or null if no column is found.

Throws:

Instance member GetPreviousColumn(startColumn, includeFilter, excludeFilter)

Returns the last DataGridViewColumn prior to the given column in display order that matches the includeFilter and excludeFilter .

ParameterTypeDescription
startColumnDataGridViewColumnThe column from which to start searching for the previous column.
includeFilter optionalDataGridViewElementStatesA combination of the DataGridViewElementStates values for inclusion.
excludeFilter optionalDataGridViewElementStatesA combination of the DataGridViewElementStates values for exclusion.

Returns: DataGridViewColumn. The previous column that matches the given filters, or null if no column is found.

Throws:

Instance member IndexOf(column)

Returns the index of the given DataGridViewColumn in the collection.

ParameterTypeDescription
columnDataGridViewColumnThe DataGridViewColumn to return the index of.

Returns: Int32. The index of the given DataGridViewColumn.

Instance member IndexOf(name)

Returns the index of the DataGridViewColumn with the specified name from the collection.

ParameterTypeDescription
nameStringThe name of the column to find.

Returns: Int32. The index of the given DataGridViewColumn.

Throws:

Instance member Insert(index, column)

Inserts a DataGridViewColumn at the given index in the collection.

ParameterTypeDescription
indexInt32The zero-based index at which to insert the given column.
columnDataGridViewColumnThe DataGridViewColumn to insert.

Throws:

or column already belongs to a DataGridView control;

or the column 's SortMode property value is Automatic and the SelectionMode property value is FullColumnSelect

or ColumnHeaderSelect. Use the control's BeginInit and EndInit methods to temporarily set conflicting property values;

or the column 's InheritedAutoSizeMode property value is ColumnHeader and the ColumnHeadersVisible property value is false;

or column has an InheritedAutoSizeMode property value of Fill and a Frozen property value of true;

or column has DisplayIndex and Frozen property values that would display it among a set of adjacent columns with the opposite Frozen property value;

or the DataGridView control contains at least one row and column has a CellType property value of null.

Protected member OnCollectionChanged(action, element)

Fires the CollectionChanged event.

ParameterTypeDescription
actionCollectionChangeActionOne of CollectionChangeAction indicating the reason the collection has changed.
elementObjectThe element that was added or removed from the collection, or null.

Instance member Remove(column)

Removes the specified DataGridViewColumn from the collection.

ParameterTypeDescription
columnDataGridViewColumnThe column to delete.

Throws:

Instance member Remove(name)

Removes the DataGridViewColumn with the specified name from the collection.

ParameterTypeDescription
nameStringThe name of the column to delete.

Throws:

Instance member RemoveAt(index)

Removes the DataGridViewColumn at the given index in the collection.

ParameterTypeDescription
indexInt32The index of the column to delete.

Throws:

Instance member SetColumnIndex(column, newIndex)

Moves the specified column to the new newIndex .

ParameterTypeDescription
columnDataGridViewColumnColumn to move to the new newIndex .
newIndexInt32New index and display index of the column .

This method updates both the column's index in the column collection and the display index without firing the ColumnDisplayIndexChanged event.

Events

Instance member CollectionChanged

CollectionChangeEventHandler Fired when the collection changes.