473,504 Members | 13,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

displaying key-value pairs in comboboxes

Hi All,
I am using a dll function that returns a two diamensional array
containing BankNames and RoutingIds. I need to display BankNames and
RoutingIds in two different comboboxes. When user selects an item in any of
these two comboboxes, I need to pick the matching item in another combobox.
Right now I store the values in a module level two diamensional array and
when user selects a bankname or routingid I loop through the array to find a
matching value. Is there any way to avoid looping through the array. I
thought I could use an ArrayList. But since all of the items will be string,
I don't think using ArrayList is good idea. Has anyone written a
StringArrayList? Is there any other better way to do this?

Thanks.
Nov 16 '05 #1
1 9365
Try this code:

public class ValuePair
{
private string _s1;
private string _s2;

public ValuePair(string s1, string s2)
{
_s1 = s1;
_s2 = s2;
}

public string S1
{
get { return _s1; }
}
public string S2
{
get { return _s2; }
}
}

ArrayList list = new ArrayList();

list.Add(new ValuePair("s1","1"));
list.Add(new ValuePair("s2","2"));
list.Add(new ValuePair("s3","3"));
list.Add(new ValuePair("s4","4"));
list.Add(new ValuePair("s5","5"));
list.Add(new ValuePair("s6","6"));

comboBox1.DisplayMember = "S1";
comboBox1.ValueMember = "S1";
comboBox1.DataSource = list;

comboBox2.DisplayMember = "S2";
comboBox2.ValueMember = "S2";
comboBox2.DataSource = list;

With this code, setting one combobox to "s4" makes the other one show "4".
Chris

"Nikhil Patel" <ni********@aol.com> wrote in message
news:e5**************@TK2MSFTNGP10.phx.gbl...
Hi All,
I am using a dll function that returns a two diamensional array
containing BankNames and RoutingIds. I need to display BankNames and
RoutingIds in two different comboboxes. When user selects an item in any of these two comboboxes, I need to pick the matching item in another combobox. Right now I store the values in a module level two diamensional array and
when user selects a bankname or routingid I loop through the array to find a matching value. Is there any way to avoid looping through the array. I
thought I could use an ArrayList. But since all of the items will be string, I don't think using ArrayList is good idea. Has anyone written a
StringArrayList? Is there any other better way to do this?

Thanks.

Nov 16 '05 #2

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

Similar topics

7
11817
by: Joe | last post by:
I am using Access 2003 and are linking to an Oracle 9i ODBC datasource (using Oracle ODBC drivers). After linking the tables in Access, I inspect the data contained in the linked tables. For...
9
2324
by: Susan Bricker | last post by:
Greetings. I am having trouble populating text data that represents data in my table. Here's the setup: There is a People Table (name, address, phone, ...) peopleID = autonumber key There...
2
1092
by: Frank | last post by:
Hi! I just run into a problem wich some of you might be able to solve really quickly so i decided to give this group a shot. In the database a have 2 tables (well, to make it easy here). 1)...
2
1690
by: lakepeir | last post by:
The return key is a special character. I'm trying to display the return key by coping the special character into a character array. When I run my app, the return key (arrow) does not display. Can...
13
3854
by: hornedw | last post by:
I have been working on a ecommerce website for myself. What I needed some assistance on was when i was trying to display the categories/subcategories for the different products. I decided to use...
1
1547
by: Gary Brown | last post by:
Hi, How do you keep an application from displaying its icon in the Task Switcher menu? Winamp, among others, do it and I have some applications should work similarly. Thanks, Gary
13
2864
by: David W. Fenton | last post by:
I've been struggling the last two days with something I thought was very easy, which is to open a web page with a form on it and populate the form with data passed in a query string (either POST or...
16
4479
by: Akhenaten | last post by:
I must be missing something rather obvious. I have the following snippet of code that echo's my result twice when it should be echoing just once (only one element in the array). What am I...
16
2074
by: =?Utf-8?B?VGFtbXkgTmVqYWRpYW4=?= | last post by:
Hi, I am using Visual C# window to dispaly a set of questions with their answers. The users should be able to move to the next question by clicking on next button. I am going to use only one panel...
3
1436
by: OldBirdman | last post by:
Each time I move to a different record, I want to display a picture, if available, stored separately from the database. If I have more than one picture, then I will put navagation arrows below the...
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7366
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
7017
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
5610
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
5026
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
4698
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
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.