I have a text box on my form that I've got set to read from from my binding
source, so when ever I mighlight a row, that text box has the row ID in it.
Now how do I assign that value to a variable for use in other area of my
program?
Thanks
Ignacio Machin ( .NET/ C# MVP ) - 06 Sep 2007 15:12 GMT
Hi,
>I have a text box on my form that I've got set to read from from my binding
>source, so when ever I mighlight a row, that text box has the row ID in it.
>Now how do I assign that value to a variable for use in other area of my
>program?
Can you use the TextChanged event?
Jason - 06 Sep 2007 15:32 GMT
I'm not exactly sure what you mean.
I was hoping to do somthing like string x = testbox1.value; but I guess it's
not that simple.
> Hi,
>
[quoted text clipped - 4 lines]
>
> Can you use the TextChanged event?
Ignacio Machin ( .NET/ C# MVP ) - 06 Sep 2007 15:59 GMT
Hi,
> I'm not exactly sure what you mean.
> I was hoping to do somthing like string x = testbox1.value; but I guess
> it's not that simple.
And that is what you are going to do, inside the event handler
you do like:
textbox1.TextChanged += new EventHandler( mymethod);
void mymethod(object sender, EventArgs e)
{
string x = testbox1.value
}
something like that.
Tim Van Wassenhove - 06 Sep 2007 19:35 GMT
> I have a text box on my form that I've got set to read from from my binding
> source, so when ever I mighlight a row, that text box has the row ID in it.
> Now how do I assign that value to a variable for use in other area of my
> program?
Thus, you already have something as the following:
BindingSource bs = ...;
textBox1.Databindings.Add("Text", bs, "MyProperty");
Now, if you want to use this value elsewhere you have two options:
string alt1 = textBox1.Text;
string alt2 = (bs.Current as TheTypeOfYourObject).MyProperty.ToString();

Signature
Kind regards,
Tim Van Wassenhove <url:http://www.timvw.be/>