Click here to Skip to main content
16,016,605 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a couple of questions in regards to designing a combobox in Visualstudio 2008(C#) 1)I have a combobox(Firstname+Lastname) datasource-SQL table. On the dropdown of the combobox, the formating looks fine, but when the name is selected,I see that the names with the trailing spaces in between them.Is there a way I can trim these and set it to work like a dropdown list. 2) I would like to have the first value in the combobox as spaces or someother text.I tried adding values in the ListItem Collection editor.but this seemed to work only in a dropbox and not in the combobox. Thanks in advance for your help.
Posted

1 solution

Hi,

If you want to retrieve your data from SQL into a combo box you will need to format this in your query.

For example:

select Rtrim(ltrim(firstname))+' ' +Rtrim(ltrim(surname)) as name from customers

Then you will bind name to your combo box
 
Share this answer
 
Comments
Sonycj 29-Mar-12 10:23am    
Thankyou very much, for explaining so very well.As for the 2nd question, the ListItem Collection editor did work after all.

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