英語で読む

次の方法で共有


SearchDirectionHint 列挙型

定義

ListViewItem を検索する方向に関するヒントを提供します。

C#
public enum SearchDirectionHint
継承
SearchDirectionHint

フィールド

名前 説明
Down 40

現在の項目の下方向。

Left 37

現在の項目の左方向。

Right 39

現在の項目の右方向。

Up 38

現在の項目の上方向。

次のコード例では、 列挙体を使用する方法を SearchDirectionHint 示します。 この例を実行するには、次のコードを Windows フォームに貼り付け、フォームのコンストラクターまたはLoadイベント処理メソッドから を呼び出InitializeLocationSearchListViewします。

C#
ListView iconListView = new ListView();
TextBox previousItemBox = new TextBox();

private void InitializeLocationSearchListView()
{
    previousItemBox.Location = new Point(150, 20);

    // Create an image list for the icon ListView.
    iconListView.LargeImageList = new ImageList();
    iconListView.Height = 400;
    
    // Add an image to the ListView large icon list.
    iconListView.LargeImageList.Images.Add(
        new Bitmap(typeof(Control), "Edit.bmp"));

    // Set the view to large icon and add some items with the image
    // in the image list.
    iconListView.View = View.LargeIcon;
    iconListView.Items.AddRange(new ListViewItem[]{
        new ListViewItem("Amy Alberts", 0), 
        new ListViewItem("Amy Recker", 0), 
        new ListViewItem("Erin Hagens", 0), 
        new ListViewItem("Barry Johnson", 0), 
        new ListViewItem("Jay Hamlin", 0), 
        new ListViewItem("Brian Valentine", 0), 
        new ListViewItem("Brian Welker", 0), 
        new ListViewItem("Daniel Weisman", 0) });
    this.Controls.Add(iconListView);
    this.Controls.Add(previousItemBox);

    // Handle the MouseDown event to capture user input.
   iconListView.MouseDown +=
       new MouseEventHandler(iconListView_MouseDown);
    //iconListView.MouseWheel += new MouseEventHandler(iconListView_MouseWheel);   
}

void iconListView_MouseDown(object sender, MouseEventArgs e)
{
    
    // Find the an item above where the user clicked.
    ListViewItem foundItem =
        iconListView.FindNearestItem(SearchDirectionHint.Up, e.X, e.Y);

    // Display the results in a textbox..
    if (foundItem != null)
        previousItemBox.Text = foundItem.Text;
    else
        previousItemBox.Text = "No item found";
}

注釈

この列挙は、 クラスと ListViewItem クラスのListViewメソッドと、 クラスによってSearchForVirtualItemEventArgs使用FindNearestItemされます。 コントロール内の ListView 最も近い項目の識別は、アプリケーションが実行されているオペレーティング システムによって異なる場合があります。そのため、検索方向はヒントであり、結果の絶対的な保証ではありません。

適用対象

製品 バージョン
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9