473,327 Members | 2,012 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.

combobox usage

hi

i have a screen with customer details on it. for some items i only want to
make a combobox available. eg. country - this will hold a defined list of
countries. my question is how i set up the datasource etc. on this combo. of
course, when opening the screen, i want the existing value for this customer
to be shown, eg. UK. but the actual source values of the combo should come
from another table - eg. the countries table.

i'm a little confused on how to set this up, any help appreciated.

rgds,
barry
Mar 20 '06 #1
3 1611
Hi Barry,

More details, please.
What is stored in the "another table"? (Examples)

In the compobox lets say we have:
"UK"
"Norway"'
"Ireland"

What do the "actual source values" look like?

Regards,
Lars-Inge Tønnessen
Mar 20 '06 #2
hi lars-inge

thanks for your response. in the main table, i have standard name and
address details, eg. NAME, ADDRESS, POSTCODE, COUNTRY, TELEPHONE. the
COUNTRY field i want to be a dropdown combo. in this table there is a 2
digit code, eg. UK, DE, US, FR etc.

the other table is the lookup table for countries. in here i have the same
2-char country code as above, along with extra info on the country eg.
LONGNAME, SHORTNAME, POPULATION, CONTINENT etc. there is a fixed list of
countries that must be chosen from - ie. no free-text.

in the drop-down i can show either the 2-char code, or the LONGNAME for
example, whichever's easiest. but when the name/address window opens, it
must display the correct value for that particular record.

so, selection of the dropdown is not friving the name&address record that is
selected, it is just altering the particular field value for this record.
hope that helps your understanding of my problem.

many thanks,
barry

"Lars-Inge Tønnessen (VJ# MVP)" wrote:
Hi Barry,

More details, please.
What is stored in the "another table"? (Examples)

In the compobox lets say we have:
"UK"
"Norway"'
"Ireland"

What do the "actual source values" look like?

Regards,
Lars-Inge Tønnessen

Mar 21 '06 #3
You can do this in many ways. One of them could be to join the tables in a
SQL Server (if your data source is a database).

An other solution would be to store all the data in the comboBox item. You
can to this by implementing your own ComboListItem that stores the full text
and the short "key".

public class ComboListItem
{
private string _LongName = "";
private string _ShortName = "";

public virtual string LongName
{
get
{
return this._LongName;
}
set
{
this._LongName = value;
}
}

public virtual string ShortName
{
get
{
return this._ShortName;
}
set
{
this._ShortName = value;
}
}

public override string ToString()
{
return this._LongName;
}
}
When you make an object of this class, you would store what the user should
see in the combobox in the LongName-field, and the key in the ShortName
field.

ComboListItem itm = new ComboListItem();
itm.LongName = "England";
itm.ShortName = "UK";
this.comboBox1.Items.Add(itm);

You can now read out the short name from the selected value, or search
through the items in the combobox and show the wanted item.
Regards,
Lars-Inge Tønnessen
Mar 21 '06 #4

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

Similar topics

2
by: Ed From NY | last post by:
I have a combobox that is loaded with last name from a table. I want to click on the persons last name, and have all the ADO.NET bound textboxes on a form load with the clicked persons data. I can...
7
by: Malcolm Cook | last post by:
Hi, I've created and installed a custom UDF to populate my combobox, and have defined it per :...
1
by: Stephen.Hunter | last post by:
Hello Everybody (anybody)? I am trying to appent a combobox to include data entered by a user which is Not In List. I have came accross this code from Allen Browne which seems to be what I am...
3
by: Lubomir | last post by:
Hi, I have a combobox and datagrid in a form. When an Item is selected from a combobox, a method is called, which will make selection from a database according selected item and populate...
9
by: Steffen Laser | last post by:
Hi group, I have a problem that I already have posted to the german C# newsgroup. Since nobody could help me there, I'd like to try it here again: I set the selected item of a combobox like...
2
by: trevor.niemack | last post by:
Hello I want to have a combobox that saves all the input, so if I put the word test in the combobox and submit a query I want to have test saved so that the next time I go to that combobox I can...
3
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...
19
by: active | last post by:
I'm using a ComboBox to display objects of a class I've defined, say CQQ. Works great except somehow I occasionally set an Item to a String object instead of an object of type CQQ. It looks...
9
by: Cralis | last post by:
I have a List of data objects. I need to populate a ComboBox with the 'Description' field from the objects. I can do that with cmbBx.Items.Add( myObject.Description.ToString() ); myObject has 2...
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.