3
I’m trying to get the value of a ListBox
from the selected index of another ListBox
, but it doesn’t work. What I have so far:
for (int i = 0; i < 10; i++)
{
Lst_ListBoxA.Add(2 * (3 * i) * 4);
Lst_ListBoxB.Add(2 * (3 / i) * 4);
}
private void Lst_ListBoxB_SelectedIndexChanged(object sender, EventArgs e)
{
//Aqui, o usuário seleciona o segundo índice (1).
string Valor = Lst_ListBoxA.GetItemText(Lst_ListBoxB.SelectedIndex);
MessageBox.Show(valor);
}
What is being returned, or shown in Messagebox, is the selected index of Lst_ListBoxB
, 1, and not the corresponding index value of Lst_ListBoxA
, 24, what would be the right way to do it?
Webforms or Windows Forms?
– user6026
I edited the tags,
winforms
.– ptkato