473,569 Members | 2,701 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 9372
Try this code:

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

public ValuePair(strin g 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.Displ ayMember = "S1";
comboBox1.Value Member = "S1";
comboBox1.DataS ource = list;

comboBox2.Displ ayMember = "S2";
comboBox2.Value Member = "S2";
comboBox2.DataS ource = 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******** ******@TK2MSFTN GP10.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
11822
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 tables that involve a number field as the primary key, the data is returned successfully. For tables that involve a character field (e.g. CHAR(3) or...
9
2328
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 is a Judge Table (information about judges) judgeID = autonumber key
2
1097
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) Question 2) Answer Each question has multiple answers attached to it. this means that
2
1699
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 someone offer advice on displaying return, backspace, etc? Thanks.
13
3860
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 the modified preorder tree transversal algorithm. What I wanted was on the first page is to display the catogories as follows Books (35)...
1
1553
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
2879
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 GET). I got Application.FollowHyperlink *kind* of working, but was having problem with double encoding of some characters (I had to do special...
16
4488
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 overlooking? ******************************** $OpenQ = mysql_query("SELECT column FROM table WHERE q_uid = $_SESSION AND status = 1",$db); // SQL query...
16
2081
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 to display one question and move to next question. Can someone please help me with the codes on coding "Next" button? Thanks -- Nejadian
3
1442
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 first picture shown. I know how to display these pictures without having them embedded in the tables. The form is bound to a table with PK=autonum....
0
7612
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7672
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5512
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
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 we have to send another system
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.