473,327 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

How do you set the value member of a combo box

I have recently migrated to VS.Net 2005, and I am struggling to do something
very basic with the combo box. I want to manually loop through a data table
and add both the display text and the value manually. The reason I cannot
bind the combo box to my data table is that there are more than one field
that I want to combine to be the display member. So what I had to do was
create yet another data table at run time (or an array list) and combine the
columns in my new data table so it would display the way I want it to. This
is much more code than simply lookping through my original data table and
adding the item and setting the value manually. I don't want to have to do
this for every combo box in the application. is it possible to set the value
member of a combo box item without binding it to a data source?

I also noticed that when I set the display member to a field that has a
space in it (i.e. [last name]) the value member displays.
Jun 20 '07 #1
1 2556
Bind to an array of objects (or fill the Combo Items collection with
objects) whose class implements a property (let's name it 'Text') which
build the display information from the various needed part of the object,
then set that property name ('Text' in our example) as the display member of
the combo.

/LM
"mfm" <mf*@discussions.microsoft.comwrote in message
news:15**********************************@microsof t.com...
>I have recently migrated to VS.Net 2005, and I am struggling to do
something
very basic with the combo box. I want to manually loop through a data
table
and add both the display text and the value manually. The reason I cannot
bind the combo box to my data table is that there are more than one field
that I want to combine to be the display member. So what I had to do was
create yet another data table at run time (or an array list) and combine
the
columns in my new data table so it would display the way I want it to.
This
is much more code than simply lookping through my original data table and
adding the item and setting the value manually. I don't want to have to
do
this for every combo box in the application. is it possible to set the
value
member of a combo box item without binding it to a data source?

I also noticed that when I set the display member to a field that has a
space in it (i.e. [last name]) the value member displays.

Jun 21 '07 #2

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

Similar topics

2
by: Terry Bickle | last post by:
Please forgive me for using the wrong term here or there. I'm an old Excel 4 macro guy who didn't convert to VB and I'm tinkering with an Access 2000 DB. I'm sure there is a simple Access 101...
8
by: Lyn | last post by:
Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". ...
1
by: meganrobertson22 | last post by:
Hi Everyone- I am trying to use a simple macro to set the value of a combo box on a form, and I can't get it to work. I have a macro with 2 actions: OpenForm and SetValue. I can open my form,...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
20
by: MLH | last post by:
120 MyString = "How many copies of each letter do you need?" 150 MyVariant = InputBox(MyString, "How Many?", "3") If MyVariant = "2" Then MsgBox "MyVariant equals the string '2'" If...
2
by: shumaker | last post by:
I have a combobox that is very much like the one found in the RSS project here: http://msdn.microsoft.com/vstudio/express/visualCSharp/learning/ My projectNameComboBox basically is filled with a...
3
by: Dave | last post by:
I would like to have the word "Select" as the default option in a combo box that will retrieve its data from database. I also would like to have the ability to validate the combo box to ensure that...
2
by: =?Utf-8?B?UGFvbG8=?= | last post by:
Having problems with combo box Display Member and Value Member. Using a typed dataset I have the following: private void frmMain_Load(object sender, EventArgs e) { cmbxPayee.DisplayMember =...
2
by: Infog | last post by:
Using this code, the display member of the combo box is displaying the text "System.Data.DataViewManagerListItemTypeDescriptor". Huh??? The first block of code gets the data from the database, and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.