User Control and Binding

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've got a user control in v1.1 VS2003 and am curious if/how I can implement
binding. I'm *thinking* I'd like something like:

MyControl.Value=<bound to some object being updated elsewhere>

Is this possible?
 
What kind of data do you expect your control to display?
Is it a single value, a list or a table?
 
At the moment, my Value property is declared as an Object so i can handle any
type. In reality, it's going to be either a string or a number so I've
considered just making the property a string. Because the control does
number based value comparisons, making it a string just means I need to
validate that Value is a number before I consider doing my comparisons (right
now, I just check if type is String else I assume its a number and do my
compares...probably not exactly right but good for the moment).
 
Generally, you'd need to have the object that you use to bind, to raise some
event whenever its value is been changed. Hookup into this event in your user
control and update the display value. You'd probably should have 2 properties
- similar to how data bainding is implemwented in .NET - DataSource and
DataMember.
 
Back
Top