Re: Databinding to a combo box: Newbie
- From: bob <startatbob_clegg@xxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 27 Mar 2007 12:02:46 +1200
Hi,
Suggest a class / struct that has place holders for m,n,o
Override the ToString function to return the 'look' that you want the
Combobox to display.
In the data retrieval create and fill a instance of the class for each
set of m,n,o
Add the class instances to the combo box.
The combobox will display the ToString output but the Selected item
will be an instance of your class so you can interact easily with m or
n or o.
HTH
Bob
public struct stTuple
{
public string m;
public string n;
public string o;
public override string ToString()
{
return "M " + m + " N " + n + " O " + o;
}
}
private void Form1_Load(object sender, EventArgs e)
{
stTuple a = new stTuple();
a.m = "mvalue";
a.n = "nvalue";
a.o = "ovalue";
stTuple b = new stTuple();
b.m = "mbvalue";
b.n = "nbvalue";
b.o = "obvalue";
this.comboBox1.Items.Add(a);
this.comboBox1.Items.Add(b);
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs
e)
{
stTuple s =(stTuple)(this.comboBox1.SelectedItem);
MessageBox.Show("Selected o value is " + s.o);
}
On 26 Mar 2007 14:39:59 -0700, "weird0" <amirediwan@xxxxxxxxx> wrote:
I want to bind data to combo box from a db that returns something.
like three tuples with the content m,n,o of the same field. How can i
do that?
Can i just store the result in an array of string and add
sequentially m....n....o . Is their anyway?
Let me know how can i do it. Refer to some good link to learn to bind
combo box to db as to what i
want to do.
- References:
- Databinding to a combo box: Newbie
- From: weird0
- Databinding to a combo box: Newbie
- Prev by Date: Re: Most robust way to implement single-instance Windows app?
- Next by Date: Re: Help with error: "No overload for method 'x' takes 'y' arguments" using web service
- Previous by thread: Databinding to a combo box: Newbie
- Next by thread: Re: Databinding to a combo box: Newbie
- Index(es):
Relevant Pages
|