Export (0) Print
Expand All

GridColumnStylesCollection.IndexOf Method

Gets the index of a specified DataGridColumnStyle.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public int IndexOf (
	DataGridColumnStyle element
public int IndexOf (
	DataGridColumnStyle element
public function IndexOf (
	element : DataGridColumnStyle
) : int



The DataGridColumnStyle to find.

Return Value

The zero-based index of the DataGridColumnStyle within the GridColumnStylesCollection or -1 if no corresponding DataGridColumnStyle exists.

Use the Contains method to determine if a specific DataGridColumnStyle exists. If so, and you need the index of the element within the collection, use the IndexOf method.

The following code example uses the Contains method to determine if a given DataGridColumnStyle exists in a GridColumnStylesCollection. If so, the IndexOf method returns the index of the DataGridColumnStyle, and the Remove method is invoked with the index to remove the element from the collection.

function RemoveCol(dc : DataColumn){
  var myGridColumns : GridColumnStylesCollection =

    var i = myGridColumns.IndexOf(myGridColumns("FirstName"));

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

© 2015 Microsoft