Last event

E

esha

When Form is invoked with
myForm.Show
what is the last event of the form object?
I have some code in TextChanged events of many TextBoxes and other controls
populated with data from datatable via BindingSourse. I want to set the flag
blnDataChanged = True only when data changed by the user, not when data in
controls is changed by initial populating. I think the flag should be set to
false after all events of the form have been fired. But I tried Activated,
Shown and some others and all the time the flag is set to true after initial
load of the form

Thanks
Esha
 
C

Cor Ligthert [MVP]

Esha,

Than take care that all intitialisation is done before the events are set.

This depends really how to do on the language you are using and than it is
even better to ask this in a language group because of that.

Have a look at the newsgroups
microsoft.public.dotnet.languages.vb (or csharp or vs)
or
microsoft.public.dotnet.jsharp

I hope you find your solution soon,

Cor
 
C

Chris Dunaway

esha said:
When Form is invoked with
myForm.Show
what is the last event of the form object?
I have some code in TextChanged events of many TextBoxes and other controls
populated with data from datatable via BindingSourse. I want to set the flag
blnDataChanged = True only when data changed by the user, not when data in
controls is changed by initial populating. I think the flag should be set to
false after all events of the form have been fired. But I tried Activated,
Shown and some others and all the time the flag is set to true after initial
load of the form

Thanks
Esha

Then do it in the form's constructor. Create a bool and set it to true
in the constructor. Then inside the TextChanged events for your
textboxes, check that bool. If it is true, then just exit the
TextChanged event. Then, in the OnShown event or at the end of the
Load event, set the bool to false to indicate that loading is done.
 
E

esha

Thank you.
I tried your scenario and set bool to false on both - at the end of Load and
in Shown. In both cases TextChanged event fired before and after. When it
fired before it was not doing anything, but after I set bool to false it did
what I did not want to.
So I'm still looking for the form event which is fired last.
 
C

Cor Ligthert [MVP]

Esha,

My problem is that I cannot find it any more, I thought that Kevin, Peter or
one of their collegues has showed this in a nice reply in the VB.Net
language newsgroup.

There are two sequences depending on what you are doing I thought that had
to do with closing or not closing, but those I do not remember me at the
moment.

I have tried to find this on MSDN, but most probably because of the new
search engine I am not able to find that anymore in a reasonable time (there
are some nice articles about this on MSDN).

Maybe you can try it yourself.

Cor
 
C

Chris Dunaway

esha said:
Thank you.
I tried your scenario and set bool to false on both - at the end of Load and
in Shown. In both cases TextChanged event fired before and after. When it
fired before it was not doing anything, but after I set bool to false it did
what I did not want to.
So I'm still looking for the form event which is fired last.

At the beginning of the constructor, you set it to *true*. Then inside
the Text_Changed event you check the value of the variable. If it is
true, you simply exit the method and don't execute the code. The
TextChanged event will still fire, but the code inside it will not be
executed. Then at the end of FormShown, you set that variable to false
so that the TextChanged event code will execute normally.

I think FormShown might be the last event but I'm not sure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top