468,532 Members | 1,690 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,532 developers. It's quick & easy.

setting focus to control after validation

I have a number of controls on a tab page. I want to validate them all
when the user tries to leave the tab. I then want to highlight the
first control which fails validation. How can I do this? I try setting
focus but something seems to set the focus back to the control which
had it before validation. Any ideas?

TIA,
KK
Jan 12 '08 #1
3 1856
If you are using MFC, see MFC Library Reference TN026: DDX and DDV Routines
Jan 14 '08 #2
On 14 Jan, 19:46, "Sheng Jiang[MVP]" <sheng_ji...@hotmail.com.discuss>
wrote:
If you are using MFC, see *MFC Library Reference TN026: DDX and DDV Routines
Thanks, but I'm not using MFC, that's why I posted in a dotnet forum.

KK
Jan 14 '08 #3

<ke***********@googlemail.comwrote in message
news:a4**********************************@s13g2000 prd.googlegroups.com...
>I have a number of controls on a tab page. I want to validate them all
when the user tries to leave the tab. I then want to highlight the
first control which fails validation. How can I do this? I try setting
focus but something seems to set the focus back to the control which
had it before validation. Any ideas?
What is the call stack when you change the focus? If it is in the middle of
processing a focus change event then something might indeed change the focus
afterward.

You could post a custom message to yourself and set the focus then, it will
be placed at the end of the message queue instead of setting the focus
synchronously. The .NET way of doing PostMessage to another thread is with
Control.BeginInvoke, I'm not sure how that would work on the same thread.
I'd use the real PostMessage just to be safe. Or for pure .NET, a winforms
timer could work too.
>
TIA,
KK

Jan 31 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Nitin | last post: by
5 posts views Thread by tshad | last post: by
reply views Thread by Miquel | last post: by
2 posts views Thread by Vinod I | last post: by
7 posts views Thread by saurabh | last post: by
1 post views Thread by Praveena.Alapati | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.