|
-
Dec 8th, 2006, 12:23 AM
#1
Thread Starter
Hyperactive Member
Determine if button was clicked...
Hi all, i have the following situation on a Windows Mobile 5 device :
I have some validation on the lost focus event of a control. However when the user clicks on the Cancel button, the lost focus event of the above control is triggered before the click event, which is normal i guess, but validation error messages are displayed while the form is closing. Is there a way in the lost focus event or any other work around to determine if the Cancel button was clicked or something so that I can suppress validation messages then? I was checking if the Cancel button had focus to do this but I think its not a very elegant solution. Please note that i'm using C#.
-
Dec 8th, 2006, 04:52 AM
#2
Fanatic Member
Re: Determine if button was clicked...
if your using Visual Studio 05 have you tried using the causesvalidation property on the controls?
or else maybe create a member variable on the form m_closing as boolean = false
then on the form_closing event set this m_closing = True
then in the lost_Focus event try If Not m_closing Then
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
-
Dec 8th, 2006, 12:16 PM
#3
Re: Determine if button was clicked...
That'll be tough, because the control loses focus before anything associated with the next control (the cancel button) is fired.
Personally, I really don't like using LostFocus, but that bias comes from desktop systems, and may be totally irrelevant to the smaller PDA etc. programming. The issue with desktop systems was that the event may NEVER fire. On a portable, I'd want to confirm that the event was fired if control was switched to a new programl.
If you find that there is an alternative time to do the validation, that might be the best solution. Otherwise, if the solution you have works, it might be the best way, even if it isn't elegant. The only alternatives I could think of were variants of what you posted.
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|