Custom displaymember in comboBox

B

Bill Nguyen

How can I have the comboBox display valuemember in addition to the column
specified in displaymember?
For example, I want to display stationID 1999 (valuemember) and stationName
such as "1999 - Station 1999" .

Any help is greatly appreciated.

Thanks

Bill
 
L

Lucky

hi Bill,
if you are fetching data from the database then u can do it in
Query itself. try this: "select ValueMember + ' - ' + displayMember as
DisMember,ValueMember from TableX"
 
C

Cor Ligthert [MVP]

Lucky,

No that is not the way, you can add an extra column in the datatable with an
expression, however most don't like that way.

Cor
 
L

Lucky

hi Cor,
of course people wont go that way. do u know how much it costs to add
one column in the DB Table? and whats ths worng in using this Query.
can u tell me the flaws in this Query. coz i've done this in my project
and it is working fine. why not to get most out of the SQL when it is
providing.
i definatly would like to have your views on this dude.
 
C

Cor Ligthert [MVP]

Lucky,
of course people wont go that way. do u know how much it costs to add
one column in the DB Table? and whats ths worng in using this Query.
can u tell me the flaws in this Query. coz i've done this in my project
and it is working fine. why not to get most out of the SQL when it is
providing.
i definatly would like to have your views on this dude.

It cost this statemement

dt.columns.add("MyDisplayValue",Gettype(System.String),"First + Second")

Cor
 
B

Bill Nguyen

I'm using Lucky's tip now since I need to get it done quickly but I would
like to use Cor's later on.
Thank you both!

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top