語言

ListView.FindItemWithText 方法

定義

找到 ListViewItem 第一個,以給定的文字值開頭。

多載

名稱 Description
FindItemWithText(String, Boolean, Int32)

尋找以指定文字值開頭的第一個 ListViewItem 或 ListViewItem.ListViewSubItem。 搜尋從指定的索引開始。

FindItemWithText(String, Boolean, Int32, Boolean)

尋找以指定文字值開頭的第一個 ListViewItem 或 ListViewItem.ListViewSubItem。 搜尋從指定的索引開始。

FindItemWithText(String)

找到以指定文字值開頭的第一個 ListViewItem 。

FindItemWithText(String, Boolean, Int32)

來源:
ListView.cs
來源:
ListView.cs
來源:
ListView.cs
來源:
ListView.cs
來源:
ListView.cs

尋找以指定文字值開頭的第一個 ListViewItem 或 ListViewItem.ListViewSubItem。 搜尋從指定的索引開始。

public:
 System::Windows::Forms::ListViewItem ^ FindItemWithText(System::String ^ text, bool includeSubItemsInSearch, int startIndex);
public System.Windows.Forms.ListViewItem FindItemWithText(string text, bool includeSubItemsInSearch, int startIndex);
public System.Windows.Forms.ListViewItem? FindItemWithText(string text, bool includeSubItemsInSearch, int startIndex);
member this.FindItemWithText : string * bool * int -> System.Windows.Forms.ListViewItem
Public Function FindItemWithText (text As String, includeSubItemsInSearch As Boolean, startIndex As Integer) As ListViewItem

參數

text
String

要搜尋的文字。

includeSubItemsInSearch
Boolean

true將子項目納入搜尋;否則,。 false

startIndex
Int32

從搜尋開始的項目索引。

傳回

第一個 ListViewItem 是從指定的文字值開頭。

例外狀況

startIndex 小於 中 的數量 ListView項目 0 或大於 。

備註

搜尋不區分大小寫。

該 text 參數可指定所需匹配文本的子字串。 此外,此方法會回傳以指定文字開頭的第一個項目。 例如,若 a ListView 包含兩個清單項目——第一個項目的文字設定為「angle bracket」,第二個項目的文字設定為「bracket」,則 FindItemWithText 呼叫通過「brack」作為參數,將回傳該項目的文字為「bracket」。

當清單為空或無匹配項目時,該 FindItemWithText 方法會回傳 null 。

適用於

FindItemWithText(String, Boolean, Int32, Boolean)

來源:
ListView.cs
來源:
ListView.cs
來源:
ListView.cs
來源:
ListView.cs
來源:
ListView.cs

尋找以指定文字值開頭的第一個 ListViewItem 或 ListViewItem.ListViewSubItem。 搜尋從指定的索引開始。

public:
 System::Windows::Forms::ListViewItem ^ FindItemWithText(System::String ^ text, bool includeSubItemsInSearch, int startIndex, bool isPrefixSearch);
public System.Windows.Forms.ListViewItem FindItemWithText(string text, bool includeSubItemsInSearch, int startIndex, bool isPrefixSearch);
public System.Windows.Forms.ListViewItem? FindItemWithText(string text, bool includeSubItemsInSearch, int startIndex, bool isPrefixSearch);
member this.FindItemWithText : string * bool * int * bool -> System.Windows.Forms.ListViewItem
Public Function FindItemWithText (text As String, includeSubItemsInSearch As Boolean, startIndex As Integer, isPrefixSearch As Boolean) As ListViewItem

參數

text
String

要搜尋的文字。

includeSubItemsInSearch
Boolean

true將子項目納入搜尋;否則,。 false

startIndex
Int32

從搜尋開始的項目索引。

isPrefixSearch
Boolean

true允許部分配對;否則,。 false

傳回

第一個 ListViewItem 是從指定的文字值開頭。

例外狀況

startIndex 小於 0 或大於 中 ListView項目的數量。

備註

當清單為空或無匹配項目時,該 FindItemWithText 方法會回傳 null 。

搜尋不區分大小寫。

該 text 參數可指定所需匹配文本的子字串。 此方法會回傳以指定文字開頭的第一個項目,除非 false 傳遞給 isPrefixSearch。 例如,若 a ListView 包含兩個清單項目——第一個項目的文字設定為「angle bracket」,第二個項目的文字設定為「bracket」,則 FindItemWithText 呼叫將「brack」作為搜尋文字,會回傳該項目的文字為「bracket」。 若 isPrefixSearch 設為 false,則此呼叫將返回 null。

適用於

FindItemWithText(String)

來源:
ListView.cs
來源:
ListView.cs
來源:
ListView.cs
來源:
ListView.cs
來源:
ListView.cs

找到以指定文字值開頭的第一個 ListViewItem 。

public:
 System::Windows::Forms::ListViewItem ^ FindItemWithText(System::String ^ text);
public System.Windows.Forms.ListViewItem FindItemWithText(string text);
public System.Windows.Forms.ListViewItem? FindItemWithText(string text);
member this.FindItemWithText : string -> System.Windows.Forms.ListViewItem
Public Function FindItemWithText (text As String) As ListViewItem

參數

text
String

要搜尋的文字。

傳回

第一個 ListViewItem 是從指定的文字值開頭。

範例

以下程式碼範例示範了此 FindItemWithText 方法。 要執行此範例,請將以下程式碼貼入 Windows 表單,並從表單的建構子或InitializeFindListView事件處理器呼叫該Load方法。 點擊按鈕查看方法呼叫的結果。

// Declare the ListView and Button for the example.
ListView findListView = new ListView();
Button findButton = new Button();

private void InitializeFindListView()
{
// Set up the location and event handling for the button.
    findButton.Click += new EventHandler(findButton_Click);
    findButton.Location = new Point(10, 10);
    
// Set up the location of the ListView and add some items.
findListView.Location = new Point(10, 30);
    findListView.Items.Add(new ListViewItem("angle bracket"));
    findListView.Items.Add(new ListViewItem("bracket holder"));
    findListView.Items.Add(new ListViewItem("bracket"));

    // Add the button and ListView to the form.
    this.Controls.Add(findButton);
    this.Controls.Add(findListView);
}

void findButton_Click(object sender, EventArgs e)
{
        // Call FindItemWithText, sending output to MessageBox.
    ListViewItem item1 = findListView.FindItemWithText("brack");
     if (item1 != null)
         MessageBox.Show("Calling FindItemWithText passing 'brack': " 
             + item1.ToString());
     else
         MessageBox.Show("Calling FindItemWithText passing 'brack': null");
 }
' Declare the ListView and Button for the example.
Private findListView As New ListView()
Private WithEvents findButton As New Button()


Private Sub InitializeFindListView()

    ' Set up the location and event handling for the button.
    findButton.Location = New Point(10, 10)

    ' Set up the location of the ListView and add some items.
    findListView.Location = New Point(10, 30)
    findListView.Items.Add(New ListViewItem("angle bracket"))
    findListView.Items.Add(New ListViewItem("bracket holder"))
    findListView.Items.Add(New ListViewItem("bracket"))

    ' Add the button and ListView to the form.
    Me.Controls.Add(findButton)
    Me.Controls.Add(findListView)

End Sub

Private Sub findButton_Click(ByVal sender As Object, ByVal e As EventArgs) _
    Handles findButton.Click

    ' Call FindItemWithText, sending output to MessageBox.
    Dim item1 As ListViewItem = findListView.FindItemWithText("brack")
    If (item1 IsNot Nothing) Then
        MessageBox.Show("Calling FindItemWithText passing 'brack': " _
            & item1.ToString())
    Else
        MessageBox.Show("Calling FindItemWithText passing 'brack': null")
    End If

End Sub

備註

搜尋不區分大小寫。

該 text 參數可指定所需匹配文本的子字串。 此外,此方法會回傳以指定文字開頭的第一個項目。 例如,若 a ListView 包含兩個清單項目——第一個項目的文字設定為「angle bracket」,第二個項目的文字設定為「bracket」,則呼叫 FindItemWithText pass brack 為參數的項目會回傳該項目的文字為「bracket」。

當清單為空或無匹配項目時,該 FindItemWithText 方法會回傳 null 。

適用於