Вопрос

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