Search code examples
c#listbox

c# listBox.GetItemText broken


This is in a for statement

listBox2.SelectedIndex = b;
vGame = listBox2.GetItemText(listBox2.SelectedItem);

This works, however I don't want to use the SelectedIndex because I have a data loaded when you click an item in the list, so I tried:

vGame = listBox2.GetItemText(b);

and the value is just 0, how do I fix this?


Solution

  • ok I got it fixed finally, I tried a bunch of things but after looking up the GetItemText they had an example of Items as array [], I tried () (I'm so used to vb6)

    this works: vGame = listBox2.GetItemText(listBox2.Items[b]);