FlexGrid for WinForms
IndexOf(String,Boolean,Int32) Method
Example 



Column name to look for (case-insensitive).
Whether to throw and exception if the column cannot be found.
The search starting index.
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.
Syntax
'Declaration
 
Public Overloads Function IndexOf( _
   ByVal columnName As String, _
   ByVal throwIfNotFound As Boolean, _
   ByVal startIndex As Integer _
) As Integer
'Usage
 
Dim instance As ColumnCollection
Dim columnName As String
Dim throwIfNotFound As Boolean
Dim startIndex As Integer
Dim value As Integer
 
value = instance.IndexOf(columnName, throwIfNotFound, startIndex)

Parameters

columnName
Column name to look for (case-insensitive).
throwIfNotFound
Whether to throw and exception if the column cannot be found.
startIndex
The search starting index.

Return Value

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.
Remarks
If the throwIfNotFound parameter is set to true and a column named columnName cannot be found, the control throws an System.ArgumentOutOfRangeException. This makes it easier to write compact code that relies on column names.
Example
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);
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ColumnCollection Class
ColumnCollection Members
Overload List

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Send Feedback