System.Web.UI.WebControls Namespace DataGridColumnCollection Class
Returns the index of the specified DataGridColumn in the collection.
[ VB ]
Public Function IndexOf ( _
ByVal column As Column _
) As Integer
[ C# ]
public int IndexOf (
Column column
);
[ C++ ]
public: int IndexOf (
Column* column
);
[ JScript ]
public function IndexOf (
column : Column
) : int;
- column
- The DataGridColumn to search for.
The index of the specified DataGridColumn in the DataGridColumnCollection. The default value is -1, which indicates that the specified column object is not found.
Use this method to determine the index number of a specified DataGridColumn derived object in the DataGridColumnCollection. If the specified DataGridColumn object is not found, an index of -1 is returned.
The following example demonstrates how to use the IndexOf method to determine the index of a DataGridColumn derived object in a DataGridColumnCollection.
void getIndex ( Object src, EventArgs e ) {
myLabel.Text = "The indexes of the columns: <br>";
foreach ( DataGridColumn column in myGrid.Columns ) {
myLabel.Text += column.HeaderText + " = " +
myGrid.Columns.IndexOf ( column ) + "<br>";
}
}
Sub getIndex ( src As Object, e As EventArgs )
myLabel.Text = "The indexes of the columns: <br>"
Dim column As DataGridColumn
For Each column In myGrid.Columns
myLabel.Text = column.HeaderText & " = " &_
myGrid.Columns.IndexOf ( column ) & "<br>"
Next column
End Sub |
|
C# |
VB |
DataGridColumnCollection Members