Home All Groups Group Topic Archive Search About

Can I ignore xxxChanged events while data binding?

Author
17 Feb 2006 12:16 PM
Larry Lard
Here's the scenario:

Show the user a list of Things. User picks one, and the Thing edit
frame is populated with the details of the Thing they picked. This
frame has Save / Discard buttons that are initially disabled. When the
user makes a change to any of the details of the Thing, those buttons
become enabled (because there are now changed to Save or Discard).

So I have a ThingDirty property, and all the xxxChanged events of the
Thing detail controls set ThingDirty = True, and in the Property Set of
ThingDirty, I set the Enabled of the Save / Discard buttons to the new
value of ThingDirty. Furthermore, I set ThingDirty to False just after
populating the detail area.

Almost perfect. Except - when the user picks a thing, the detail area
is populated through the magic of data binding - and this triggers all
those xxxChanged events. So every time a Thing is selected, the Save /
Discard buttons briefly flash enabled (as the data binding happens)
before being set disabled.

My workaround is a horrible form-level variable called
dataBindingInProgress, which I manually set/reset around the data read
operation, and which when set tells the Property Set *not* to touch the
Enabled of the buttons. Is there a more'built-in' way? Like a property
on the BindingSource (or somewhere) that means 'binding in progress'?
So the controls can know they are being *initialised* and not *changed*
?

--
Larry Lard
Replies to group please

Author
17 Feb 2006 1:23 PM
Peter Proost
Hi Larry

you could use removehandler and addhandler on the controls, remove all the
handlers before databinding and then add them again afterwards

Hope this helps

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

Show quoteHide quote
"Larry Lard" <larryl***@hotmail.com> schreef in bericht
news:1140178600.713875.189700@g44g2000cwa.googlegroups.com...
> Here's the scenario:
>
> Show the user a list of Things. User picks one, and the Thing edit
> frame is populated with the details of the Thing they picked. This
> frame has Save / Discard buttons that are initially disabled. When the
> user makes a change to any of the details of the Thing, those buttons
> become enabled (because there are now changed to Save or Discard).
>
> So I have a ThingDirty property, and all the xxxChanged events of the
> Thing detail controls set ThingDirty = True, and in the Property Set of
> ThingDirty, I set the Enabled of the Save / Discard buttons to the new
> value of ThingDirty. Furthermore, I set ThingDirty to False just after
> populating the detail area.
>
> Almost perfect. Except - when the user picks a thing, the detail area
> is populated through the magic of data binding - and this triggers all
> those xxxChanged events. So every time a Thing is selected, the Save /
> Discard buttons briefly flash enabled (as the data binding happens)
> before being set disabled.
>
> My workaround is a horrible form-level variable called
> dataBindingInProgress, which I manually set/reset around the data read
> operation, and which when set tells the Property Set *not* to touch the
> Enabled of the buttons. Is there a more'built-in' way? Like a property
> on the BindingSource (or somewhere) that means 'binding in progress'?
> So the controls can know they are being *initialised* and not *changed*
> ?
>
> --
> Larry Lard
> Replies to group please
>
Author
17 Feb 2006 5:30 PM
Patrice
Not sure but you could also try SuspendBinding. REsumeBindig...

--

Show quoteHide quote
"Larry Lard" <larryl***@hotmail.com> a écrit dans le message de
news:1140178600.713875.189700@g44g2000cwa.googlegroups.com...
> Here's the scenario:
>
> Show the user a list of Things. User picks one, and the Thing edit
> frame is populated with the details of the Thing they picked. This
> frame has Save / Discard buttons that are initially disabled. When the
> user makes a change to any of the details of the Thing, those buttons
> become enabled (because there are now changed to Save or Discard).
>
> So I have a ThingDirty property, and all the xxxChanged events of the
> Thing detail controls set ThingDirty = True, and in the Property Set of
> ThingDirty, I set the Enabled of the Save / Discard buttons to the new
> value of ThingDirty. Furthermore, I set ThingDirty to False just after
> populating the detail area.
>
> Almost perfect. Except - when the user picks a thing, the detail area
> is populated through the magic of data binding - and this triggers all
> those xxxChanged events. So every time a Thing is selected, the Save /
> Discard buttons briefly flash enabled (as the data binding happens)
> before being set disabled.
>
> My workaround is a horrible form-level variable called
> dataBindingInProgress, which I manually set/reset around the data read
> operation, and which when set tells the Property Set *not* to touch the
> Enabled of the buttons. Is there a more'built-in' way? Like a property
> on the BindingSource (or somewhere) that means 'binding in progress'?
> So the controls can know they are being *initialised* and not *changed*
> ?
>
> --
> Larry Lard
> Replies to group please
>