Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,
in my application i am using a combo boxa nd binding data to display member and value member.
i can fetch the selected value by using
Combo1.SelectedValue.ToString
but i can't fetch the display value .

can any one help me out.
thanx in advance
Posted
Updated 29-Jun-22 1:29am

Have you tried Combo1.SelectedText?
 
Share this answer
 
Comments
souravghosh18 9-Oct-10 7:26am    
yes but it is not working
Ankur\m/ 9-Oct-10 7:36am    
Not working means? I mean give details.
Put a break point and debug to see what's the issue. You can also check values of various properties of the combobox while debugging.
Goutam Patra 9-Oct-10 7:57am    
Yes, I have edited the answer, Please check it. And moreover SelectedText gives the Text of the Highlighted Selection ie the text you select by pressing Shift key.
Use Combo1.SelectedValue.ToString for the value
and Combo1.Text for the Selected Text
 
Share this answer
 
v2
Comments
Ankur\m/ 9-Oct-10 7:47am    
He needs to get the value of selected text and not selected value. Moreover he already used the same to get the value.
Read the question again.
binoyvijayan 3-Dec-12 2:00am    
its not working;

try this code:

string name=((DataRowView)ComboBox1.Items[e.Index])["Name"].ToString();
Thanks
To get data from displaymember of combobox, please use

N = position data of table

me.textbox1.text = Combo1.SelectedItem(N)
 
Share this answer
 
Comments
CHill60 24-Oct-19 4:32am    
Wrong. A combobox will only allow you to select a single item (it is not a listbox). Therefore you cannot apply an index to the selected items - SelectedItem(N)
In any event, you should not be assigning an object to the textbox text property, at the very least using .ToString().
The question was actually answered 9 years ago.
Hi from Venezuela,

Try this:

DataTable sistemas = LogicaSistema.CargarTablaSistema(cboSoftware.SelectedValue.ToString());
            if (sistemas.Rows.Count == 0)
            {
                return;
            }
            DataRow row = sistemas.Rows[0];
            nombresistema = row[1].ToString();
            MessageBox.Show(nombresistema);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900