Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB.NET Combo Box: How to show two row

Posted on 2004-04-19
9
Medium Priority
?
572 Views
Last Modified: 2012-05-04
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??
0
Comment
Question by:nibirkhan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 5

Expert Comment

by:chaniewskim
ID: 10863129
What exactly do you want to achieve? Could you give some example?
0
 
LVL 2

Author Comment

by:nibirkhan
ID: 10863667
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?
0
 
LVL 5

Expert Comment

by:chaniewskim
ID: 10863842
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.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Author Comment

by:nibirkhan
ID: 10863962
could you please tell me detials or code??
0
 
LVL 5

Expert Comment

by:chaniewskim
ID: 10863995
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?
0
 
LVL 2

Author Comment

by:nibirkhan
ID: 10864035
you are right.....thats what i want to do basically..

0
 
LVL 5

Expert Comment

by:chaniewskim
ID: 10864055
Ok, so that is straightforward? Or isn't it? If not, could you explain your problem again in more details?
0
 
LVL 2

Author Comment

by:nibirkhan
ID: 10864189
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??
0
 
LVL 5

Accepted Solution

by:
chaniewskim earned 2000 total points
ID: 10864246
OK,
the first thing (to show them in tow columns so that I have enough space between them) is problematic, because that DropDownList control simply doesn't work that way. You could concatenate strings like I shown you in the above SELECT sample and use few spaces to provide necessary gap, but it is difficult to do this so all the values are idented the same.

If you don't need to display an Employee ID on the list, but only want to assign it, then you can do it very simple:

- assign EmpName to DataTextField of your DropDownList control, and
- assign EmpID to DataValueField of that control.

Then bind DropDownList control to DataReader object using it's DataSource attribute.

Do you know how to bind it this way? Or do you need more details?
I'm going to bed now, probably I will answer you tomorow. It is 00.33 in Poland now :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question