Re: Databinding to custom class by Paul
Paul
Fri Oct 24 10:38:12 CDT 2003
Hi Dave,
You don't have to handle these events yourself (unless you want to)
My understanding (and experience with) is that when you databind a property
to a control it automatically 'listens' for those events to update the
control when that property whenever that event is raised.
You will also want the RaiseEvent to be in the Property Set method (see
below)
I have had great success with this myself. Another option (although not as
nice) is to create a Typed Dataset from your class and then bind to the
dataset. I have done this as well, but it is more work and not as slick (in
my opinion)
Hope this helps.
cheers,
Paul
"Joe" <joe_dh_@hotmail.com> wrote in message
news:1066958711.473989@Virginia.BMTS.Com...
> Thanks for the help.
>
> I'm still a little confused though - so, do I have to catch these events
in
> my form and act on them, or should the value of the bound control be
updated
> automatically?
>
> I have something like this:
>
> public class myclass
> public event TextChanged as EventHandler
>
> private pText as string
>
> public property text as string
> get
> return pText
> end get
> set(byval value as string)
> pText = value
'**************************************************************
'this is where you raise the event
'**************************************************************
RaiseEvent TextChanged(me, new EventArgs())
> end set
> end property
>
> public sub doStuff()
> pText = "doing stuff"
> RaiseEvent TextChanged(me,new EventArgs())
> end sub
> end class
>
> Now if I call doStuff() from my form, with a TextBox bound to the text
> property, nothing happens to the value in the TextBox.
>
> Thanks again,
>
> Dave Hagedorn
>
>
>