473,785 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2166
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...@ho tmail.com.discu ss>
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.comw rote in message
news:a4******** *************** ***********@s13 g2000prd.google groups.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.BeginIn voke, 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2219
by: Nitin | last post by:
Hi I have created function to check date and time. at the time of execution, if date is left empty the function returns the error message but then the focus goes to next field. Next filed is for time and there is also a check on that. If time is empty return error message. Again the explorer returns error message and then shifts the focus to date field, again error message and focus goes to time and this story goes on and on, untill...
5
11381
by: tshad | last post by:
I have a date validation function that I want to stay at the object I am validating if there is a Validation error, but it always goes to the next object. The Javascript: function ValidateForm(me){ var dt=me if (isDate(dt.value)==false){ dt.focus()
0
1898
by: ED M. | last post by:
Hello all...I'm new to the board. I have a problem that I hope someone here might be able to solve for me. I am doing some clientside validation using Javascript. The text I am testing is within a textbox that is part of a datagrid. To complicate things, the datagrid is part of a user control. The following code is all part of the user control. The validation part of the script works fine. However, when I try to set the focus...
0
5084
by: Miquel | last post by:
Hi all. I felt frustrated when developing an 'UserControl' derivated from textBox, because sequence event (and Validate event) seems to fail. I Always thought my code was wrong. But after trying the UserControl a lot of hours I have the feeling that c# (or .Net) fails. Thus, I have developed a simple program with 3 textBox, 1 Botton and 1 ListBox (for showing results) which fire OnEnter, OnGotFocus,
2
1101
by: Vinod I | last post by:
Hi Team, I am using validator controls. Please let me know how to set the focus back to the control after validation. Thanks in advance... cheeeeeeeeers!!!
7
1562
by: saurabh | last post by:
Hey, I have a form in which there are say 10 fields. I am using validator control for all the fields. suppose user forgets to fill field no. 5, 8 , 9 and 10. So on clicking the save button,obviously an error willl be raised. Is there anyway such that when the error is raised the focus goes to first control that has false validation (e.g in our case that control is 5) ? Right now after clicking the save button, none of the control has...
3
2825
by: vivela | last post by:
hi, I hope you could help me out on this one,cause I have been trying for 4 days to solve it,but couldn't quite get it right: I have an ASP textbox that should change the value in a dropdownlist. this happens,but the problem is with the validation of the ddl.it has a requiredfieldvalidator,and the error message disapears only if i select a value from the dropdownlist,even though it should also disapear when I write a valid name in the...
1
2516
by: Praveena.Alapati | last post by:
Hi, There is a tab control on a page with multiple tabs and handful of controls in each tab. The way it's rendered in html (like grid etc..) is in table format in tablerows and cells. On clientside, on form validation in javascript, I would like to set focus on to one of the tabs and set the focus to the control on that tab.
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10090
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9949
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.