Link to home
Start Free TrialLog in
Avatar of nibirkhan
nibirkhan

asked on

VB.NET Combo Box: How to show two row

Hi,

How can I show two row on my combo box in VB.NET? Access forms does a good job with it but I don't know how to do it on VB.NET?

Any Help??
Avatar of chaniewskim
chaniewskim

What exactly do you want to achieve? Could you give some example?
Avatar of nibirkhan

ASKER

on my table has two fields,

I want to show both of them EmpID and EmpName, but my bound column will be EmpID,

got it?
Yeah, got it.

You could do this on SQL Server side, by returning a concatenation of those columns and then using resulting column as DataTextField, or,
if you're using a typed dataset, you can make a custom calculated column configuring it in dataset schema. But I think that first solution would be better and easier.
could you please tell me detials or code??
When you're returning data from database for filling that combobox, simply do:

SELECT ...., EmpID + ' ' + EmpName AS EmpLabel, .... FROM MyTable....

then simply use EmpLabel for DataTextField of combobox, the same like you were doing with EmpID alone.

Why would you want to do that anyway? Looking at those field names it seems that you'd like to have EmpName bound to DataTextField and EmpId to DataValueField - or am I wrong?
you are right.....thats what i want to do basically..

Ok, so that is straightforward? Or isn't it? If not, could you explain your problem again in more details?
well, I understand what you are saying, you are saying to bring them in to one column but I need to show them in tow columns so that I have enough space between them...also one of them will be bound column,

or,

If I can do this: My combo box will show Employee Name but it will assign the relative value of Employee ID on the table.... any help for this??
ASKER CERTIFIED SOLUTION
Avatar of chaniewskim
chaniewskim

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial