QUOTE(Chris Evans @ 18 Jun, 2008 - 09:45 AM)

Hi
This is driving me round the twist.
All I want to do is from a populated Combo box retrieve the currently selected value so that I can pass it to some other method.
I have a combo box called cmboLetters with values set :
AB
BC
CD
DE
This was set in the collection of the control on the gui in VS2005
I have set in code the first viewable item on the combo box so we are not looking at an empty entry by doing the following:
this.cmboLetters.SelectedIndex = 0;
This loads up fine. However, I cannot get the selectedIndex value. When I say value I do not mean the index.
At index[0] here it should show me "AB". Well that was what I was expecting..... :[
I have tried all of the following and the results are:
cmboLetters.SelectedText = ""
cmboLetters.SelectedText.ToString() = ""
cmboLetters.SelectedItem.ToString(); = "System.Data.DataRowView"
cmboLetters.SelectedValue.ToString(); = "System.Data.DataRowView"
cmboLetters.SelectedValue = "System.Data.DataRowView"
Can anyone help?
I know this was posted a long time ago, but I figured someone like me may be searching for an answer. I'm not really an expert (hope I'm understanding the question), but I was having a similar problem. Since I have some experience with web applications, I was expecting the combobox to behave like the dropdownlist, which it doesn't. Anyhow, I got the selected value by using
string myStr = myComboBox.Text;
It makes sense, I suppose, since users can actually type in their own values so a Combobox acts as a Textbox as well.