TextBox lost focus

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Hi,
I write in Windows Forms 2.0. I have form and TexBox on the form.
I want after changing value of this textBox to raise event and update
record in database.
I want to raise this event after clicking in any part of my form. I
tried "Leave" i "LostFocus" but it works only when I click in another
control. Don't work when I click on 'background' of the form.
The best solution would be TextBox to lose focus when user click on
background.

How to do it ?

Thank you for help
 
Mark said:
Hi,
I write in Windows Forms 2.0. I have form and TexBox on the form.
I want after changing value of this textBox to raise event and update
record in database.
I want to raise this event after clicking in any part of my form.

Clicking on the Form is handled by it's click event.
I
tried "Leave" i "LostFocus" but it works only when I click in another
control. Don't work when I click on 'background' of the form.
The best solution would be TextBox to lose focus when user click on
background.

I guess you know that this is unusual behavior. However, which other control
is to get the focus then? If one control loses the focus, another one
usually gets it.
How to do it ?

Thank you for help


Armin
 
Mark said:
I write in Windows Forms 2.0. I have form and TexBox on the form.
I want after changing value of this textBox to raise event and update
record in database.
I want to raise this event after clicking in any part of my form. I
tried "Leave" i "LostFocus" but it works only when I click in another
control. Don't work when I click on 'background' of the form.
The best solution would be TextBox to lose focus when user click on
background.

I don't think this is a good idea. As Armin already wrote, the form itself
cannot have the input focus (only if there are no other controls on the
form). For which reasons would you want the value in the database to be
updated? Often it's even better to update the record in the database after
clicking an "OK" button or similar, to enable the user to discard the
changes he made.
 
Back
Top