DataGridViewColumnCollection

Wisej.Web.DataGridViewColumnCollection

Namespace: Wisej.Web

Assembly: Wisej.Framework (2.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

DataGridViewColumnCollection(dataGrid)

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

Name
Type
Description

dataGrid

The DataGridView that created this collection.

Properties

Item(index)

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

Throws:

Item(name)

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

Throws:

Methods

Add(column)

Adds the given DataGridViewColumn to the collection.

Parameter
Type
Description

Returns: Int32. The index of the column.

Throws:

Add(name)

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

Parameter
Type
Description

name

The name by which the column will be referred.

Returns: Int32. The index of the column.

Throws:

Add(name, valueType)

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

Parameter
Type
Description

name

The name by which the column will be referred.

valueType

The Type of the values in the cells.

Returns: Int32. The index of the column.

Throws:

Add(name, caption)

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

Parameter
Type
Description

name

The name by which the column will be referred.

caption

The text for the column's header.

Returns: Int32. The index of the column.

Throws:

Add(name, caption, valueType)

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

Parameter
Type
Description

name

The name by which the column will be referred.

caption

The text for the column's header.

valueType

The Type of the values in the cells.

Returns: Int32. The index of the column.

Throws:

AddRange(newColumns)

Adds a range of columns to the collection.

Parameter
Type
Description

newColumns

An array of DataGridViewColumn objects to add.

Throws:

Clear()

Clears the collection.

Throws:

Clear(dispose)

Clears the collection and disposes the columns.

Parameter
Type
Description

dispose

Contains(column)

Determines whether the collection contains the given DataGridViewColumn.

Parameter
Type
Description

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

Contains(name)

Determines whether the collection contains the given DataGridViewColumn.

Parameter
Type
Description

name

The name of the column to look for.

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

CopyTo(array, index)

Copies the items from the collection to the given array.

Parameter
Type
Description

array

The destination DataGridViewColumn array.

index

The index of the destination array at which to start copying.

GetColumnCount(includeFilter)

Returns the number of columns that match the includeFilter .

Parameter
Type
Description

includeFilter

A combination of the DataGridViewElementStates values for inclusion.

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

Throws:

GetColumnsWidth(includeFilter)

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

Parameter
Type
Description

includeFilter

A 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:

GetFirstColumn(includeFilter, excludeFilter)

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

Parameter
Type
Description

includeFilter

A combination of the DataGridViewElementStates values for inclusion.

excludeFilter

A 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:

GetLastColumn(includeFilter, excludeFilter)

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

Parameter
Type
Description

includeFilter

A combination of the DataGridViewElementStates values for inclusion.

excludeFilter

A 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:

GetNextColumn(startColumn, includeFilter, excludeFilter)

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

Parameter
Type
Description

startColumn

The column from which to start searching for the next column.

includeFilter

A combination of the DataGridViewElementStates values for inclusion.

excludeFilter

A combination of the DataGridViewElementStates values for exclusion.

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

Throws:

GetPreviousColumn(startColumn, includeFilter, excludeFilter)

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

Parameter
Type
Description

startColumn

The column from which to start searching for the previous column.

includeFilter

A combination of the DataGridViewElementStates values for inclusion.

excludeFilter

A 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:

IndexOf(column)

Returns the index of the given DataGridViewColumn in the collection.

Parameter
Type
Description

column

The DataGridViewColumn to return the index of.

Returns: Int32. The index of the given DataGridViewColumn.

IndexOf(name)

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

Parameter
Type
Description

name

The name of the column to find.

Returns: Int32. The index of the given DataGridViewColumn.

Throws:

Insert(index, column)

Inserts a DataGridViewColumn at the given index in the collection.

Parameter
Type
Description

index

The zero-based index at which to insert the given column.

Throws:

Remove(column)

Removes the specified DataGridViewColumn from the collection.

Parameter
Type
Description

column

The column to delete.

Throws:

Remove(name)

Removes the DataGridViewColumn with the specified name from the collection.

Parameter
Type
Description

name

The name of the column to delete.

Throws:

RemoveAt(index)

Removes the DataGridViewColumn at the given index in the collection.

Parameter
Type
Description

index

The index of the column to delete.

Throws:

SetColumnIndex(column, newIndex)

Moves the specified column to the new newIndex .

Parameter
Type
Description

column

Column to move to the new newIndex .

newIndex

New 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

CollectionChanged

CollectionChangeEventHandler Fired when the collection changes.

Last updated

Was this helpful?