use combo box value search multi array

  • Thread starter Thread starter G-Oker
  • Start date Start date
G

G-Oker

Guest
HI,

I have a 2d array who's 1st half I used to populate a combobox

string[,] Names2D = new string [_noOfRemotes, 2];//Two-dimensional string array

for (int i = 1; i < Convert.ToInt32(_dataINIEntries); i++)
{
Names2D[i, 0] = getIniValue("Remote", "Home" + i, "");
Names2D[i, 1] = getIniValue("Remote", "Server" + i, "");
//comboBox3.Items.Add(Names2D[i, 0] + " " + Names2D[i, 1]);
comboBox3.Items.Add(Names2D[i, 0]);
}



What I would like to do now though is , when a item iin the combo box is selected, is matching second half displays in a text box

private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox3.SelectedItem == null) return;
var b = comboBox3.SelectedItem;
if (b != null)
sourceBox.Text = b.ToString();

sourceBox.Text = "";

}

this gives me a copy of what is selected in the combobox, so I have tried adding

for (int i = 1; i < Names2D.GetLength(0); i++)
{
for (int j = 0; j < Names2D.GetLength(1); j++)
{
if (comboBox3.SelectedItem.Equals(Names2D[i, j]))
{
richTextBox1.Text += "POSITION[" + i + " , " + j + "]";
}
}

}


but this fails with a "=0" error.


can someone tell me how I can get the match other half of a 2d array to display in a textbox ?


thank you

Continue reading...
 
Back
Top