I'm trying to get the value of a ListBox
from the selected index of another ListBox
, but it does not work. What I have until the present moment:
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 the MessageBox , is the selected index of Lst_ListBoxB
, 1 , not the corresponding index value of Lst_ListBoxA
, 24 , what would be the correct way to do it?