DataView.Find 方法

定义

根据指定的排序键值在 DataView 中查找行。

重载

Find(Object[])

根据指定的排序键值在 DataView 中查找行。

Find(Object)

根据指定的排序键值在 DataView 中查找行。

Find(Object[])

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

根据指定的排序键值在 DataView 中查找行。

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

参数

key
Object[]

类型为 Object 的值的数组。

返回

DataView 中与指定的排序键值匹配的第一个行的位置索引;如果没有匹配的排序键值,则为 -1。

示例

以下 Visual Basic 示例使用 Find 方法返回在其排序键列中包含指定值的行的索引。

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

另请参阅

适用于

Find(Object)

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

根据指定的排序键值在 DataView 中查找行。

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

参数

key
Object

要搜索的对象。

返回

包含指定排序关键字值的 DataView 中的行的索引;否则为 -1(如果不存在排序关键字值)。

示例

以下 Visual Basic 示例使用 Find 方法返回包含所需排序键列中值的行的索引。

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

另请参阅

适用于