문제

is there any way to determine, that listbox selected item reached the last item?

Each item in my listbox is a link to webpages, and I want to call logout method when the last page in the list is visited.

Please advice.

도움이 되었습니까?

해결책

if (listBox.SelectedIndex == (listBox.Items.Count - 1))
{
    //...
}

Edit according to Thomas' suggestion in the comments:

You could add this code to the listBox' SelectedIndexChanged event, to react on every selection change in the Listbox:

listBox.SelectedIndexChanged += (s,e) => 
{
    if (listBox.SelectedIndex == (listBox.Items.Count - 1))
    {
        //...
    }    
};
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top