Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / January 2008

Tip: Looking for answers? Try searching our database.

setting focus to control after validation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kelvin.koogan@googlemail.com - 12 Jan 2008 14:27 GMT
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
Sheng Jiang[MVP] - 14 Jan 2008 18:55 GMT
If you are using MFC, see  MFC Library Reference TN026: DDX and DDV Routines
kelvin.koogan@googlemail.com - 14 Jan 2008 21:02 GMT
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
Ben Voigt [C++ MVP] - 31 Jan 2008 23:34 GMT
>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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.