all groups > dotnet windows forms databinding > october 2006 >
You're in the

dotnet windows forms databinding

group:

How can I bind a control to an object declared at run time?


How can I bind a control to an object declared at run time? Jamie Risk
10/26/2006 3:44:17 PM
dotnet windows forms databinding: I'm so lost. This has to be the 20th attempt at writing this
posting.

* I have a form with various controls.
* I have an object with associated properties
(accessible with get/set type of interface).
* I'd like to have the controls manipulate the
properties of the object.

Is there a way to avoid manually coding event handlers for each
of control on the form to do this?

In order to modify the (DataBindings)/Text property of say, a
textBox in the form design view I have to add data source to my
solution. Doing so gives me an option to select an 'object' as
the data source, but then I'm given only a selection of class
definitions.

How am I supposed to do this? What should I be Googling to give
me an inkling of clue?

- Jamie
Re: How can I bind a control to an object declared at run time? Bart Mermuys
10/26/2006 8:43:40 PM
Hi,

[quoted text, click to view]

So use the class DataSource to setup the bindings with the Designer. Note
that it will also put a BindingSource on the Form, then at runtime do:

YourBindingSource.DataSource = yourObject;

HTH,
Greetings


[quoted text, click to view]

Re: How can I bind a control to an object declared at run time? Jamie Risk
10/27/2006 9:55:13 AM
This was what I was exactly what I needed. A thousand thanks.

- Jamie

p.s. Now I've got my answer, I'm going to try and figure out
where I missed it in the documentation.

[quoted text, click to view]
Re: How can I bind a control to an object declared at run time? Otis Mukinfus
10/28/2006 12:44:42 PM
[quoted text, click to view]
If you want the bound objects to be editable they will need to use the IEditable
and INotifyPropertyChanged interfaces. Check the help on those two
interfaces...
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
Re: How can I bind a control to an object declared at run time? Otis Mukinfus
10/28/2006 12:49:19 PM
[quoted text, click to view]
AW Shoot, Jamie!

I should have said IEditableOject in my previous post. I make that mistake all
the time ;o)
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
AddThis Social Bookmark Button