Skip to main content
Version: 3.5

DataGridViewColumnCollection

Namespace: Wisej.Web

Assembly: Wisej.Framework (3.5.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 memberDataGridViewColumnCollection(dataGrid)

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

NameTypeDescription
dataGridDataGridViewThe DataGridView that created this collection.

Properties

Instance memberItem(index)

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

Throws:

Instance memberItem(name)

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

Throws:

Methods

Instance memberAdd(column)

Adds the given DataGridViewColumn to the collection.

ParameterTypeDescription
columnDataGridViewColumnThe DataGridViewColumn to add.

Returns: Int32. The index of the column.

Throws:

Instance memberAdd(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 memberAdd(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 memberAdd(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 memberAdd(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 memberAddRange(newColumns)

Adds a range of columns to the collection.

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

Throws:

Instance memberClear()

Clears the collection.

Throws:

Instance memberClear(dispose)

Clears the collection and disposes the columns.

ParameterTypeDescription
disposeBoolean

Instance memberContains(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 memberContains(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 memberCopyTo(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 memberGetColumnCount(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 memberGetColumnsWidth(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 memberGetFirstColumn(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 memberGetLastColumn(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 memberGetNextColumn(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 memberGetPreviousColumn(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 memberIndexOf(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 memberIndexOf(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 memberInsert(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:

Instance memberRemove(column)

Removes the specified DataGridViewColumn from the collection.

ParameterTypeDescription
columnDataGridViewColumnThe column to delete.

Throws:

Instance memberRemove(name)

Removes the DataGridViewColumn with the specified name from the collection.

ParameterTypeDescription
nameStringThe name of the column to delete.

Throws:

Instance memberRemoveAt(index)

Removes the DataGridViewColumn at the given index in the collection.

ParameterTypeDescription
indexInt32The index of the column to delete.

Throws:

Instance memberSetColumnIndex(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 memberCollectionChanged

CollectionChangeEventHandler Fired when the collection changes.