hi,
is it possible to display 2 fields in a combobox e.g., a code and a description separated by a hyphen.
Ex. 01 - Accessories
thanks,
marivic
Printable View
hi,
is it possible to display 2 fields in a combobox e.g., a code and a description separated by a hyphen.
Ex. 01 - Accessories
thanks,
marivic
The combobox by default uses the ToString function to display the item text. You can override that on whatever you are using for the items to display whatever you want.
VB Code:
Public Override Function ToString() as String return "Code - Description" End Function
hi edneeis,
sorry but its not quite clear to me how to do it.
i've created the combobox and defined the datasource, datamember, and valuemember at design time. how can i incorporate your code in mine.
thanks for your time.
What is the datasource?
im using a dataset. i defined a connection and a dataadapter and generate the dataset at design time.
can u give me example how to do it using a dataset defined at design time and populating the combo at runtime.
thanks for being patient with me.
Well unfortunately my idea didn't work. First I tried inheriting a datarow to override the Tostring, but that gave me trouble. So then I made a wrapper class that converted a datarow but the combobox doesn't like tabs so columns didn't work. I guess I'd have to ownerdraw the list into columns, but I don't have time for an example of that now.
After learning more about OwnerDrawing with the ImageCombo I decided to add the ability to have multiple columns in it. So here is an example project with a combo that is rather access like and can have multiple columns (and images if you want). I can't promise that its bug free but it seems to be working fine.
Here is a screen shot:
http://www.vbforums.com/attachment.p...postid=1225564
This version doesn't have the ability to show column headers yet but I plan on trying to add it.