TextBox.Leave's event does not trigger

  • Thread starter Thread starter Zyrthofar
  • Start date Start date
Z

Zyrthofar

Hi
I have three textboxes indicating the individual RGB values of a
color. When the user leaves a textbox (Leave event), I check the
validity of that number and saves the three values to a set of raw
data... The sub used handles the three textboxes's Leave events, and
uses the 'sender' variable...

Now I have a picturebox with GDI+ circles in it, representing the 8
different colors in the palette. You can choose the color number by
clicking on the circle.

The problem arises when I change a RGB component and change the color
number. The Leave event is not triggered, because the cursor is still
in the checkbox, and thus the last component is not saved before
switching to the chosen color.

I have tried to put the focus elsewhere when the user chooses a new
color, but it seems the Leave event is only triggered when the user
manually changes the active control.

The most intuitive way of solving the problem would be to trigger the
Leave event programatically when the user changes the color number,
but to do that I would need to know the active checkbox that was just
changed in order to pass it up as the 'sender'.

Another way to do it would be to use the TextChanged events instead of
Leave, thus saving the data everytime, but my palette would be
refreshed 16 or 24 times when the user changes the palette number or
some other things...

I would need some way to find the active control for the 'sender'
argument, but my search wasn't successful so far... The best way to
do it would be to make the program trigger the Leave event when
clicking on the circle.....

Any idea would be appreciated.

Thank you
 
Hi,

Have you tried the "validated" event instead of "leave"? I had a problem
similar to this a while back, though, and I'm fairly sure I never completely
solved it.

Another idea is to put your validation code in a separate routine and call
it EITHER when the Leave even occurs or when you click on the circle.

--George
 
Back
Top