[]
Gets the index of the Column with the specified name.
public int IndexOf(string columnName)
Type | Name | Description |
---|---|---|
string | columnName | Column name to look for (case-insensitive). |
Type | Description |
---|---|
int | Index of the column that has the given name in this collection, or -1 if the collection does not contain a column with the given name. |
Gets the index of the Column with the specified name. The search starts at a specified index.
public int IndexOf(string columnName, int startIndex)
Type | Name | Description |
---|---|---|
string | columnName | Column name to look for (case-insensitive). |
int | startIndex | The search starting index. |
Type | Description |
---|---|
int | Index of the column that has the given name in this collection, or -1 if the collection does not contain a column with the given name. |
Gets the index of the Column with the specified name, optionally throwing an exception if the column is not found.
public int IndexOf(string columnName, bool throwIfNotFound)
Type | Name | Description |
---|---|---|
string | columnName | Column name to look for (case-insensitive). |
bool | throwIfNotFound | Whether to throw and exception if the column cannot be found. |
Type | Description |
---|---|
int | Index of the column that has the given name in this collection, or -1 if the collection does not contain a column with the given name. |
If the throwIfNotFound
parameter is set to true and
a column named columnName
cannot be found, the control throws
an ArgumentOutOfRangeException. This makes it easier to write
compact code that relies on column names.
The example below uses the IndexOf method to convert column names into indices. Note that if the column names are invalid, the exception will be thrown by the IndexOf method (column not found) rather than in the following method, where it would not be as clear (invalid index).
int columnIndex = _flex.Cols.IndexOf("total");
_flex.AutoSizeCol(columnIndex);
Gets the index of the Column with the specified name, optionally throwing an exception if the column is not found. The search starts at a specified index.
public int IndexOf(string columnName, bool throwIfNotFound, int startIndex)
Type | Name | Description |
---|---|---|
string | columnName | Column name to look for (case-insensitive). |
bool | throwIfNotFound | Whether to throw and exception if the column cannot be found. |
int | startIndex | The search starting index. |
Type | Description |
---|---|
int | Index of the column that has the given name in this collection, or -1 if the collection does not contain a column with the given name. |
If the throwIfNotFound
parameter is set to true and
a column named columnName
cannot be found, the control throws
an ArgumentOutOfRangeException. This makes it easier to write
compact code that relies on column names.
The example below uses the IndexOf method to convert column names into indices. Note that if the column names are invalid, the exception will be thrown by the IndexOf method (column not found) rather than in the following method, where it would not be as clear (invalid index).
int columnIndex = _flex.Cols.IndexOf("total");
_flex.AutoSizeCol(columnIndex);