473,488 Members | 2,516 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Binding two values to combobox display member property

Any one could help how to bind two table field values
into combobox display member property. I mean i have two
fields in a table. One is states description and another
is states codes.I want to add these two fields to
combobox display property.

Any body knows this solution, post it.

Nov 17 '05 #1
2 19318
You can write your own class that takes the 2 parameters and override
ToString method. In this example, it is useless (I did it with string
because I do not know your data structure), but val1 and val2 may be in an
another type and this time, it would help you to do what you want.

class TableItem {
private string val1;
private string val2;
public TableItem(string val1, string val2) {
this.val1=val1;
this.val2=val2;
}
public override string ToString() {
return val1+" "+val2;
}
}

To add the value in you combobox, do like following :
comboBox1.Items.Add(new TableItem("first","second"));
comboBox1.Items.Add(new TableItem("third","fourth"));
comboBox1.Items.Add(new TableItem("fifth","sixth"));

Hope it helps,

Ludovic Soeur.

"Hanumanth Reddy" <an*******@discussions.microsoft.com> a écrit dans le
message de news:09****************************@phx.gbl...
Any one could help how to bind two table field values
into combobox display member property. I mean i have two
fields in a table. One is states description and another
is states codes.I want to add these two fields to
combobox display property.

Any body knows this solution, post it.

Nov 17 '05 #2
Hanumanth,

When it is a datatable you are talking about, than you can add an extra
column to that with an expression where in you have connected the other two
columns.

I hope this helps,

Cor
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2590
by: Greg Dunn | last post by:
I have two tables in a parent-child relationship. Details on the tables are as shown below: Table1 ------- Item_ID (primary key) Item_Owner (foreign key to Table2) Table2 -------
2
4683
by: Dica | last post by:
i've got a table in my dataSet that looks like this: <tblTasks> <taskID>0</taskID> <projectID>0</projectID> <summary>-- Select A Task --</summary>
4
3971
by: Keith | last post by:
Hello - this started out as a minor annoyance - and now is starting to bother me more and more - I'm hoping someone can help me. I would like to have a combobox display - NOT initially be blank...
1
1571
by: Stewart Lane | last post by:
Can the display member of a combobox who's datasource is a dataset generated from a SQl command in a data adpater BE SET to the concatenation of two fields, like fname+' '+lname? This is my SQL...
2
12493
by: AMDRIT | last post by:
Hello Everyone, I would like to format the Display Members of a combobox's datasource. Is there a way to apply a format without subclassing the original datasource? For example, given a list of...
1
1578
by: Parveen | last post by:
Is it possible to manually provide (display,value) pairs for a combo box?? The only method I'm aware of is bind the "displaymember" and "valuemember" properties of the combobox to columns in a...
3
61111
by: Nofi | last post by:
Hello, I'm trying to fill my combobox per code, not with a DataSet because I want to have an empty row in it and this wasn't possible when working with a DataSet. The fill works fine, but when I...
0
1470
by: Amit | last post by:
Hi All, Can any one write me the Code to sort datagridviewcomboboxcolumn according to display member property. By default is it sorted according to value member but I want to sort according to...
1
2971
by: shubham rastogi | last post by:
I am using a combobox.. and I want to display two columns combobox using the diplay member property...for example I have a table sam and it has two columns A and B . following are details of...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4875
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.