Frage

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.

War es hilfreich?

Lösung

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))
    {
        //...
    }    
};
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top