Glenn Patton

Glenn Patton

  • NA
  • 308
  • 82.9k

Getting at values in a list box

Jul 5 2012 12:08 PM
Hi All,

Simple question I have up loaded information to a list box using the below code
  List<SignedDriver> drivers = GetDriverInfo();
          
            foreach (SignedDriver driver in drivers)
                listBox1.Items.Add(driver.DeviceName+","+driver.DriverDate+","+driver.DriverVersion);
this displays the data, I want to check DeviceName & DriverVersion against some values however I can be sure of the exact location (on my PC it's 29 for the correct entry in the collection) however I can't garuntee it on another (Other PC's, Netbooks, Tablets etc.) so I want to be dynamic
 private void button6_Click(object sender, EventArgs e)
        {
            int index = -1;
            //USB Serial Converter  2.8.24.0
            index = listBox1.FindString("2.8.24.0");
            MessageBox.Show("index = " + index.ToString());

        } 
while I know there are multiple enteries with this in the messagebox gives -1 not the at least 2 I was expecting. I having been fighting the code too long today!

Glenn  

Answers (2)