Επεξεργασία

Κοινή χρήση μέσω


DataView.Find Method

Definition

Finds a row in the DataView by the specified sort key value.

Overloads

Find(Object[])

Finds a row in the DataView by the specified sort key values.

Find(Object)

Finds a row in the DataView by the specified sort key value.

Find(Object[])

Source:
DataView.cs
Source:
DataView.cs
Source:
DataView.cs

Finds a row in the DataView by the specified sort key values.

public:
 int Find(cli::array <System::Object ^> ^ key);
public int Find (object?[] key);
public int Find (object[] key);
member this.Find : obj[] -> int
Public Function Find (key As Object()) As Integer

Parameters

key
Object[]

An array of values, typed as Object.

Returns

The index of the position of the first row in the DataView that matches the sort key values specified; otherwise -1 if there are no matching sort key values.

Examples

The following Visual Basic example uses the Find method to return the index of a row that contains specified values in its sort key columns.

Private Sub FindValueInDataView(table As DataTable)
    Dim view As New DataView(table)
    view.Sort = "Customers"

    ' Find the customer named "John Smith".
    Dim vals(1) As Object
    vals(0)= "John"
    vals(1) = "Smith"
    Dim i As Integer = view.Find(vals)
    Console.WriteLine(view(i))
End Sub

See also

Applies to

Find(Object)

Source:
DataView.cs
Source:
DataView.cs
Source:
DataView.cs

Finds a row in the DataView by the specified sort key value.

public:
 int Find(System::Object ^ key);
public int Find (object? key);
public int Find (object key);
member this.Find : obj -> int
Public Function Find (key As Object) As Integer

Parameters

key
Object

The object to search for.

Returns

The index of the row in the DataView that contains the sort key value specified; otherwise -1 if the sort key value does not exist.

Examples

The following Visual Basic example uses the Find method to return the index of the row that contains the value in the sort key column that you want.

Private Sub FindValueInDataView(table As DataTable)
    Dim view As New DataView(table)
    view.Sort = "CustomerID"

    ' Find the customer named "DUMON" in the primary key column
    Dim i As Integer = view.Find("DUMON")
    Console.WriteLine(view(i))
End Sub

See also

Applies to