İngilizce dilinde oku

Aracılığıyla paylaş


SearchDirectionHint Sabit listesi

Tanım

öğesinin nerede aranacağıyla ilgili yönlü bir ListViewItemipucu sağlar.

C#
public enum SearchDirectionHint
Devralma
SearchDirectionHint

Alanlar

Name Değer Description
Down 40

Geçerli öğenin altında.

Left 37

Geçerli öğenin solunda.

Right 39

Geçerli öğenin sağındaki.

Up 38

Geçerli öğenin üstünde.

Örnekler

Aşağıdaki kod örneği numaralandırmanın SearchDirectionHint nasıl kullanılacağını gösterir. Bu örneği çalıştırmak için aşağıdaki kodu bir Windows Formuna yapıştırın ve formun oluşturucusundan veya Load olay işleme yönteminden çağrısı InitializeLocationSearchListView yapın.

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";
}

Açıklamalar

Bu numaralandırma, ve ListViewItem sınıflarındaki ListView yöntemler ve sınıfı tarafından SearchForVirtualItemEventArgs kullanılırFindNearestItem. Bir ListView denetimdeki en yakın öğeyi tanımlamak, uygulamanın üzerinde çalıştığı işletim sistemine bağlı olarak değişebilir; bu nedenle, arama yönü bir ipucudur ve sonuçların mutlak garantisi değildir.

Şunlara uygulanır

Ürün Sürümler
.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