ListView.SearchForVirtualItem 이벤트

정의

ListView가 가상 모드에 있고 검색이 수행되고 있으면 발생합니다.

public:
 event System::Windows::Forms::SearchForVirtualItemEventHandler ^ SearchForVirtualItem;
public event System.Windows.Forms.SearchForVirtualItemEventHandler SearchForVirtualItem;
public event System.Windows.Forms.SearchForVirtualItemEventHandler? SearchForVirtualItem;
member this.SearchForVirtualItem : System.Windows.Forms.SearchForVirtualItemEventHandler 
Public Custom Event SearchForVirtualItem As SearchForVirtualItemEventHandler 

이벤트 유형

SearchForVirtualItemEventHandler

예제

다음 코드 예제에서는이 멤버를 사용 하는 방법을 보여 줍니다. 이 예제에서 검색은 처음 1만 정사각형 목록에서 지정된 정수에 가장 가까운 일치 항목을 반환합니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 VirtualMode 속성입니다.

//This event handler enables search functionality, and is called
//for every search request when in Virtual mode.
void listView1_SearchForVirtualItem(object sender, SearchForVirtualItemEventArgs e)
{
    //We've gotten a search request.
    //In this example, finding the item is easy since it's
    //just the square of its index.  We'll take the square root
    //and round.
    double x = 0;
    if (Double.TryParse(e.Text, out x)) //check if this is a valid search
    {
        x = Math.Sqrt(x);
        x = Math.Round(x);
        e.Index = (int)x;
    }
    //If e.Index is not set, the search returns null.
    //Note that this only handles simple searches over the entire
    //list, ignoring any other settings.  Handling Direction, StartIndex,
    //and the other properties of SearchForVirtualItemEventArgs is up
    //to this handler.
}
'This event handler enables search functionality, and is called
'for every search request when in Virtual mode.
Private Sub listView1_SearchForVirtualItem(ByVal sender As Object, ByVal e As SearchForVirtualItemEventArgs) Handles listView1.SearchForVirtualItem
    'We've gotten a search request.
    'In this example, finding the item is easy since it's
    'just the square of its index.  We'll take the square root
    'and round.
    Dim x As Double = 0
    If [Double].TryParse(e.Text, x) Then 'check if this is a valid search
        x = Math.Sqrt(x)
        x = Math.Round(x)
        e.Index = Fix(x)
    End If
    'Note that this only handles simple searches over the entire
    'list, ignoring any other settings.  Handling Direction, StartIndex,
    'and the other properties of SearchForVirtualItemEventArgs is up
    'to this handler.
End Sub

설명

이 이벤트가 발생할 때를 ListView 가 가상 모드 및 FindNearestItem 또는 FindItemWithText 메서드가 호출 됩니다. 이 이벤트를 처리할 때 속성에서 제공하는 Items 항목 목록에서 검색 조건과 일치하는 항목을 계산하고 속성을 인덱ListViewItem스로 설정 SearchForVirtualItemEventArgs.Index 해야 합니다. 항목이 제공되지 FindNearestItem FindItemWithText 않으면 .null

이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생 을 참조하십시오.

적용 대상