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.