ListView.FindItemWithText メソッド

定義

指定したテキスト値で始まる最初の ListViewItem を検索します。

オーバーロード

名前 説明
FindItemWithText(String)

指定したテキスト値で始まる最初の ListViewItem を検索します。

FindItemWithText(String, Boolean, Int32)

指定したテキスト値で始まる最初の ListViewItem または ListViewItem.ListViewSubItem (指定されている場合) を検索します。 検索は、指定したインデックスから開始されます。

FindItemWithText(String, Boolean, Int32, Boolean)

指定したテキスト値で始まる最初の ListViewItem または ListViewItem.ListViewSubItem (指定されている場合) を検索します。 検索は、指定したインデックスから開始されます。

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 パラメーターは、目的の一致するテキストの部分文字列を指定できます。 さらに、このメソッドは、指定したテキストで始まる最初の項目を返します。 たとえば、ListViewに 2 つのリスト アイテム (最初の項目のテキストが "山かっこ" に設定され、2 番目の項目のテキストが "bracket" に設定されている) が含まれている場合、パラメーターとしてFindItemWithTextを渡brack呼び出すと、テキストが "角かっこ" であるアイテムが返されます。

FindItemWithText メソッドは、リストが空であるか、一致する項目がない場合にnullを返します。

適用対象

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 が 0 未満か、 ListView内の項目数を超えています。

注釈

検索では大文字と小文字が区別されません。

text パラメーターは、目的の一致するテキストの部分文字列を指定できます。 さらに、このメソッドは、指定したテキストで始まる最初の項目を返します。 たとえば、 ListView に 2 つのリスト アイテム (最初の項目のテキストが "山かっこ" に設定され、2 番目の項目のテキストが "bracket" に設定されている) が含まれている場合、パラメーターとして "中かっこ" を渡 FindItemWithText 呼び出すと、テキストが "角かっこ" であるアイテムが返されます。

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 パラメーターは、目的の一致するテキストの部分文字列を指定できます。 このメソッドは、 falseisPrefixSearchに渡されない限り、指定したテキストで始まる最初の項目を返します。 たとえば、 ListView に 2 つのリスト アイテム (最初の項目のテキストが "山かっこ" に設定され、2 番目の項目のテキストが "bracket" に設定されている) が含まれている場合、検索テキストが "bracket" であるアイテムを返す FindItemWithText 、"中かっこ" を渡す呼び出しが返されます。 isPrefixSearchfalse に設定されている場合、この呼び出しはnullを返します。

適用対象