Focus-Lost Problem

H

hula

Hello

againe a "basic" question on UserControls.

I have some UserControls inside a panel.
Inside the controls i have checkboxes, comboboxes and textboxes.
On change of any data inside the control i like to save the actual done
change.
I can do this on the checkboxes or combos, by using the events provided
by the controls.
For the textbox this is a little more tricky (as it seems to me)

I don't want to use the "TextChanged" event, as this one is called on
every keypress. As i'm saving the chages to DB this would be... lets
say absurd.
I do save the changes on the "Leave" event therefore.

My problem comes if i close the parentwindow, where the pannel and
controls are embedded, prior of changeing the focus of the textbox
previously.
Any changes to the textbox are lost then.

I don't want so save the data in the destructor, as i can't rely on it
to be called before eg. the data is displayed againe (and of course the
wrong data if GC would not have deleted the object yet).

I also don't like to implement some "Save" function in the control that
i call on Unloading of the parent window for every UserControl inside
the panel (even though i will have to do this ...).

Can anyone give some hints?

_thanks in advance
 
H

hula

hula said:
Hello

againe a "basic" question on UserControls.

I have some UserControls inside a panel.
Inside the controls i have checkboxes, comboboxes and textboxes.
On change of any data inside the control i like to save the actual done ....

I also don't like to implement some "Save" function in the control that
i call on Unloading of the parent window for every UserControl inside
the panel (even though i will have to do this ...).

Can anyone give some hints?

_thanks in advance

Ups: forgot to mention:
At the moment i solved the problem by setting the focus to some button
in the parentform, to force a "Leave" event in the usercontrol. But i
think this is not the way to do it right?
 
N

nick.fletcher

Can you not use the FormClosing event? This event fires when a request
has been made to close the form but it hasnt actually closed yet

You wont know if the text box has changed but you can force a check to
occur
 
H

hula

Can you not use the FormClosing event? This event fires when a request
has been made to close the form but it hasnt actually closed yet

You wont know if the text box has changed but you can force a check to
occur

This event is not present on UserControls
 

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