Formatting a combo box to include a heading.
Greetings everyone,
Is there a way to format a combo box so that the data returned from the database can have a heading. Example:
ID Name
1 Franks
2 Jane
So basically, programming in the heading information before the data is returned. The only data return from the database is ID numbers and Names, not the heading. Lastly, I did not to use a Rich Textbox because the user needs to make a selection in order to perform deletion. Thank in advance.
Re: Formatting a combo box to include a heading.
Quote:
Originally Posted by
franconomic
Greetings everyone,
Is there a way to format a combo box so that the data returned from the database can have a heading. Example:
ID Name
1 Franks
2 Jane
So basically, programming in the heading information before the data is returned. The only data return from the database is ID numbers and Names, not the heading. Lastly, I did not to use a Rich Textbox because the user needs to make a selection in order to perform deletion. Thank in advance.
What is your query for the database?
Re: Formatting a combo box to include a heading.
The query is select * all. Then I just simply selected to use the columns that I want to use...
Re: Formatting a combo box to include a heading.
Quote:
Originally Posted by
franconomic
The query is select * all. Then I just simply selected to use the columns that I want to use...
This is a bad practice. If you don't need all the data, why query for all? It's a waste of resources.
Re: Formatting a combo box to include a heading.
Doesn't make a lot of sense... if the header gets displayed in the combo, it bcomes selectable... plus, does the user really need to see the ID? I would think they would be more interested in the name part. I would set the displaymember to the name, the valuemember to the id, then set the combo's datasource to your datatable... then the user gets the very nice name Col in the display... and you get the ID value when using the .Value property.
-tg
Re: Formatting a combo box to include a heading.
Comboboxes are not designed to display tabular data. If you want to show your data in tabular format, use another control that is more suited, such as a datagridview.
Re: Formatting a combo box to include a heading.
Normally I'd agree... but I have seen (and used) multi-column drop downs before... they are handy when you need them... but this is a case where it's not needed.
-tg