Results 1 to 3 of 3

Thread: Determine if button was clicked...

  1. #1

    Thread Starter
    Hyperactive Member vbud's Avatar
    Join Date
    Jan 2002
    Location
    Mru 20 17S, 57 33E Goal: Get out of the BOX Status: In The Shadows!!! Target Posts: 3,000,000,000
    Posts
    378

    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#.
    >!v!<
    Free your mind, stop thinking
    http://inspirone.blogspot.com

    Please rate this post if it helped you

  2. #2
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    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

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    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
  •  



Click Here to Expand Forum to Full Width