combobox items
-
How do I access the item from the drop down list when I click the button? Chindiwo Jnr. Programmer -----
ComboBox.SelectedItem
mav -
ComboBox.SelectedItem
mav -
Mav this a good e.g of what I want to do label1.Text = combobox.SelectedItme. and if I do that, there's errors Chindiwo Programmer -----
-
Mav this a good e.g of what I want to do label1.Text = combobox.SelectedItme. and if I do that, there's errors Chindiwo Programmer -----
That's simple: label1.Text is of type string, combobox.SelectedItem is of type object, that's what the error most likely tells you. Reading (and understanding!) the errors you get is the key to successful programming. Convert the object to string by using ToString() for example. Try:
if (combobox.SelectedItem != null)
label1.Text = combobox.SelectedItem.ToString();Regards, mav
-
That's simple: label1.Text is of type string, combobox.SelectedItem is of type object, that's what the error most likely tells you. Reading (and understanding!) the errors you get is the key to successful programming. Convert the object to string by using ToString() for example. Try:
if (combobox.SelectedItem != null)
label1.Text = combobox.SelectedItem.ToString();Regards, mav