TextBox lost focus

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
 
A

Armin Zingler

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
 
H

Herfried K. Wagner [MVP]

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.
 

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