|
-
Oct 14th, 2002, 04:10 AM
#1
Thread Starter
Addicted Member
display 2 fields in a combobox
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
-
Oct 14th, 2002, 04:23 AM
#2
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
-
Oct 14th, 2002, 05:09 AM
#3
Thread Starter
Addicted Member
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.
-
Oct 14th, 2002, 10:06 AM
#4
-
Oct 14th, 2002, 08:10 PM
#5
Thread Starter
Addicted Member
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.
-
Oct 15th, 2002, 11:57 AM
#6
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.
-
Oct 19th, 2002, 04:02 AM
#7
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.
Last edited by Edneeis; Oct 19th, 2002 at 07:47 PM.
-
Oct 19th, 2002, 04:03 AM
#8
Here is a screen shot:
This version doesn't have the ability to show column headers yet but I plan on trying to add it.
Last edited by Edneeis; Oct 19th, 2002 at 07:50 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|