Home All Groups Group Topic Archive Search About

How do you know when all databindings on form are complete?

Author
22 Mar 2006 5:15 PM
JohnR
I'm running into a 'timing' or 'race' condition on my form.  All textbox
controls are bound to a datasource,  but certain other controls (like
labels) need to be updated when you move to a different record. In addition
some of the databound controls need to be modified (ie: verified) based on
the values of other databound controls.  For example, if one checkbox is
checked, then I need to ensure that another databound control has a certain
value.

The problem is that I can't figure out what event fires when ALL the
databound controls have been updated.   Before I start verifying and
updating controls on the form, I want to make sure that all of them have the
latest information.  If I use the ControlA.textchanged event how do I know
that ControlB has been updated already? and vice versa.

Does anybody have any suggestions as to how I can determine if all databound
controls have been updated?

Thanks, John

Author
22 Mar 2006 5:35 PM
Cor Ligthert [MVP]
John,

Do you know that there are databinding event s, for me sounds that the place
as a start as solution for your problem in the way you build it.

Have a look at this sample on our website, maybe will it help you.

http://www.vb-tips.com/default.aspx?ID=c4832a2a-2b95-4ded-93d9-4deb7fa4a0b8

Cor

"JohnR" <JohnR***@hotmail.com> schreef in bericht
news:rCfUf.1561$kB1.1399@trndny07...
Show quoteHide quote
> I'm running into a 'timing' or 'race' condition on my form.  All textbox
> controls are bound to a datasource,  but certain other controls (like
> labels) need to be updated when you move to a different record. In
> addition some of the databound controls need to be modified (ie: verified)
> based on the values of other databound controls.  For example, if one
> checkbox is checked, then I need to ensure that another databound control
> has a certain value.
>
> The problem is that I can't figure out what event fires when ALL the
> databound controls have been updated.   Before I start verifying and
> updating controls on the form, I want to make sure that all of them have
> the latest information.  If I use the ControlA.textchanged event how do I
> know that ControlB has been updated already? and vice versa.
>
> Does anybody have any suggestions as to how I can determine if all
> databound controls have been updated?
>
> Thanks, John
>
Author
22 Mar 2006 7:21 PM
JohnR
Hi Cor,

   Yes, I'm familiar with the parse and format events associated with a
databinding.  Trapping the event for each control on the page and then
setting some sort of flag indicating that the control was 'updated' seems
like overkill.

   Basically I think I'm looking for something simple...  how can I
programmatically test that all controls that are bound to a datasource have
been updated when the 'position' property changes???  If I can test for this
then I can update/verify/modify all the controls on the form knowing that
I'm dealing with current information.

  Otherwise I can't be sure that any particular control has been updated
yet.  I've got to think that there is something I can look at to see if the
controls are all updated.  Clearly, when the update code finishes, and the
mouse gets control and you can click around the form, then you can be sure
all controls have been updated.   Is there an event that fires 'just before'
the program starts listening for events (mouse clicks, etc) again?  I can't
imagine that this situation has not been addressed previously...

John



Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:O35EPbdTGHA.4740@TK2MSFTNGP14.phx.gbl...
> John,
>
> Do you know that there are databinding event s, for me sounds that the
> place as a start as solution for your problem in the way you build it.
>
> Have a look at this sample on our website, maybe will it help you.
>
> http://www.vb-tips.com/default.aspx?ID=c4832a2a-2b95-4ded-93d9-4deb7fa4a0b8
>
> Cor
>
> "JohnR" <JohnR***@hotmail.com> schreef in bericht
> news:rCfUf.1561$kB1.1399@trndny07...
>> I'm running into a 'timing' or 'race' condition on my form.  All textbox
>> controls are bound to a datasource,  but certain other controls (like
>> labels) need to be updated when you move to a different record. In
>> addition some of the databound controls need to be modified (ie:
>> verified) based on the values of other databound controls.  For example,
>> if one checkbox is checked, then I need to ensure that another databound
>> control has a certain value.
>>
>> The problem is that I can't figure out what event fires when ALL the
>> databound controls have been updated.   Before I start verifying and
>> updating controls on the form, I want to make sure that all of them have
>> the latest information.  If I use the ControlA.textchanged event how do I
>> know that ControlB has been updated already? and vice versa.
>>
>> Does anybody have any suggestions as to how I can determine if all
>> databound controls have been updated?
>>
>> Thanks, John
>>
>
>
Author
23 Mar 2006 6:42 AM
Cor Ligthert [MVP]
JohnR,

In fact should the control which do something be completely be seperated
from your data.

Around your data you have the rules of your busines.

In this case is a dependend from b while b is dependend from c where there
is no sequence.
The moment you know that is when you confirm that the data is well written.
In your case as I understand at a rowchange or at a button command.

That is in my opinion than the place to check if the validity of the created
data is confirm those rules, based on the methods you have in a special
class for this. (but you can start if you have nothing to do it in your code
and than replace that).

Just my idea in this.

Cor

"JohnR" <JohnR***@hotmail.com> schreef in bericht
news:nthUf.5377$8G2.5307@trndny01...
Show quoteHide quote
> Hi Cor,
>
>   Yes, I'm familiar with the parse and format events associated with a
> databinding.  Trapping the event for each control on the page and then
> setting some sort of flag indicating that the control was 'updated' seems
> like overkill.
>
>   Basically I think I'm looking for something simple...  how can I
> programmatically test that all controls that are bound to a datasource
> have been updated when the 'position' property changes???  If I can test
> for this then I can update/verify/modify all the controls on the form
> knowing that I'm dealing with current information.
>
>  Otherwise I can't be sure that any particular control has been updated
> yet.  I've got to think that there is something I can look at to see if
> the controls are all updated.  Clearly, when the update code finishes, and
> the mouse gets control and you can click around the form, then you can be
> sure all controls have been updated.   Is there an event that fires 'just
> before' the program starts listening for events (mouse clicks, etc) again?
> I can't imagine that this situation has not been addressed previously...
>
> John
>
>
>
> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
> news:O35EPbdTGHA.4740@TK2MSFTNGP14.phx.gbl...
>> John,
>>
>> Do you know that there are databinding event s, for me sounds that the
>> place as a start as solution for your problem in the way you build it.
>>
>> Have a look at this sample on our website, maybe will it help you.
>>
>> http://www.vb-tips.com/default.aspx?ID=c4832a2a-2b95-4ded-93d9-4deb7fa4a0b8
>>
>> Cor
>>
>> "JohnR" <JohnR***@hotmail.com> schreef in bericht
>> news:rCfUf.1561$kB1.1399@trndny07...
>>> I'm running into a 'timing' or 'race' condition on my form.  All textbox
>>> controls are bound to a datasource,  but certain other controls (like
>>> labels) need to be updated when you move to a different record. In
>>> addition some of the databound controls need to be modified (ie:
>>> verified) based on the values of other databound controls.  For example,
>>> if one checkbox is checked, then I need to ensure that another databound
>>> control has a certain value.
>>>
>>> The problem is that I can't figure out what event fires when ALL the
>>> databound controls have been updated.   Before I start verifying and
>>> updating controls on the form, I want to make sure that all of them have
>>> the latest information.  If I use the ControlA.textchanged event how do
>>> I know that ControlB has been updated already? and vice versa.
>>>
>>> Does anybody have any suggestions as to how I can determine if all
>>> databound controls have been updated?
>>>
>>> Thanks, John
>>>
>>
>>
>
>
Author
23 Mar 2006 11:17 AM
Larry Lard
JohnR wrote:
>    Basically I think I'm looking for something simple...  how can I
> programmatically test that all controls that are bound to a datasource have
> been updated when the 'position' property changes???  If I can test for this
> then I can update/verify/modify all the controls on the form knowing that
> I'm dealing with current information.
>
>   Otherwise I can't be sure that any particular control has been updated
> yet.  I've got to think that there is something I can look at to see if the
> controls are all updated.  Clearly, when the update code finishes, and the
> mouse gets control and you can click around the form, then you can be sure
> all controls have been updated.   Is there an event that fires 'just before'
> the program starts listening for events (mouse clicks, etc) again?  I can't
> imagine that this situation has not been addressed previously...

I haven't been able to find any better solution than a form-level
variable dataBinding As Boolean, this kind of code around the binding
operations:

        dataBinding = True
        Me.MyTableAdapter.FillByID(MyID)
        dataBinding = False

and this kind of code in the 'propagation' events:

    If Not dataBinding Then
        'whatever
    End If

Yucky I know, but I didn't get any better suggestions here. Apparently
the BindingSource (or one of those dozens of behind-the-scenes objects
data binding seems to use :)) has a bindingInProgress property, but
it's Private.

--
Larry Lard
Replies to group please
Author
25 Mar 2006 3:19 PM
Jim Hughes
Using 2005, there is a new component called BindingSource that has a
BindingCompleted event.

You bind all of your controls to the BindingSource and set the
BindingSource.DataSource to the actual data object.

Show quoteHide quote
"Larry Lard" <larryl***@hotmail.com> wrote in message
news:1143112621.165764.172920@v46g2000cwv.googlegroups.com...
>
> JohnR wrote:
>>    Basically I think I'm looking for something simple...  how can I
>> programmatically test that all controls that are bound to a datasource
>> have
>> been updated when the 'position' property changes???  If I can test for
>> this
>> then I can update/verify/modify all the controls on the form knowing that
>> I'm dealing with current information.
>>
>>   Otherwise I can't be sure that any particular control has been updated
>> yet.  I've got to think that there is something I can look at to see if
>> the
>> controls are all updated.  Clearly, when the update code finishes, and
>> the
>> mouse gets control and you can click around the form, then you can be
>> sure
>> all controls have been updated.   Is there an event that fires 'just
>> before'
>> the program starts listening for events (mouse clicks, etc) again?  I
>> can't
>> imagine that this situation has not been addressed previously...
>
> I haven't been able to find any better solution than a form-level
> variable dataBinding As Boolean, this kind of code around the binding
> operations:
>
>        dataBinding = True
>        Me.MyTableAdapter.FillByID(MyID)
>        dataBinding = False
>
> and this kind of code in the 'propagation' events:
>
>    If Not dataBinding Then
>        'whatever
>    End If
>
> Yucky I know, but I didn't get any better suggestions here. Apparently
> the BindingSource (or one of those dozens of behind-the-scenes objects
> data binding seems to use :)) has a bindingInProgress property, but
> it's Private.
>
> --
> Larry Lard
> Replies to group please
>