Tao,
You should expose that variable as a public property. Then, you can
bind to the property. For example, say your class exposes the variable
through a property named "MyProperty", you could bind a textbox to it using:
// The textbox is textbox. myInstance is the object instance.
textbox.DataBindings.Add("MyProperty", myInstance, null);
If your property changes, and you want your bindings to automatically
update as a result, then you need to expose an event with the name <property
name>Changed. This event is of type EventHandler, and you would fire the
event after the value has changed.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Tao" <Ta*@discussions.microsoft.com> wrote in message
news:4F**********************************@microsof t.com...
I am newbie to C#. Here is a question:
I want to bind a variable in my class to a control. I got tons of troubles
to do so.
Can somebody give me quick sample in C#(not VB) please.
Thanks.