i've just been through this.
binding is automatic (one-way) - i.e. from the control to the porperty of
the business object (cat)
you should find, when you bind like you have shown in example, when you tab
off the textbox (txt) the CatName property will automatically change.
The problem you'll experience is binding (pulling) data from the object.
The data binder listens for <PropName>Changed event.
What you need to do is...
public class Cat : Component, ISomeBindInterface{
private String pCatName;
public event EventHandler CatNameChange;
public String CatName{
get {return pName;}
set {
pName = value;
if (CatNameChanged!=null)
CatNameChange(this, new EventArgs());
}
}
}
HTH
Sam
"ogs" <og*@discussions.microsoft.com> wrote in message
news:F1**********************************@microsof t.com...
I need to create component that allows binding to it's properties. Maybe
there exists some interface or something.
Like:
================================================== =
public class Cat : Component, ISomeBindInterface{
private String pCatName;
public String CatName{
get {return pName;}
set {pName = value;}
}
}
...
Cat Tom = new Cat();
TextBox txt = new TextBox();
txt.DataBindings.Add(new System.Windows.Forms.Binding("Text", Tom,
"CatName", true));
==================================================
It will be very good to see this component in design-time in VS (I know
how
to do that). It needs the same functionality as all other components like
DataSet etc. - setting bindings through PropertyGrid.
Thanks a lot.