Getting rid of focus on a control

M

Marina

Hi,

Let's say there a bunch of textboxes on the screen, and there is a toolbar
on the form (Infragistics). When a button is clicked, whatever field the
user was last on needs to be validated, and then some work done based on
what the button was that got clicked.

The problem is, the validation event doesn't fire on the textbox when this
happens. In fact, clicking outside the textbox doesn't validate the textbox,
or change the fact that it still has focus.

Now, the form can also have grids, dropdowns, etc. And basically, no matter
what control last had focus, it needs to 'lose focus', so that its contents
can be validated before anything else happens.

How can I force a control to lose focus without explicitly having to give
focus to some other control? I just want the current control to lose focus,
and give focus to the form as a whole.

But basically, how do I force validation in the current control when a
button elsewhere is clicked? Right now, the last control retains focus.

Thanks
 
C

Claes Bergefall

In your button click handler, call the Validate method on your main form.
That should trigger the Validate events

/claes
 

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