Find name of next control from Validate


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Find name of next control from Validate

  1. #1
    Randy Guest

    Find name of next control from Validate



    Inside the Validate event ActiveControl is still the control firing Validate.
    How do you get the name of the control that WILL be active once Validate
    exits?

  2. #2
    Rick Rothstein Guest

    Re: Find name of next control from Validate

    If by the next control you mean the one that is next in the Tab order, then
    consider this

    Dim cntl As Control
    ......
    ......
    For Each cntl In Controls
    If Screen.ActiveControl.TabIndex + 1 _
    = cntl.TabIndex Then
    Debug.Print cntl.Name & " is the next control"
    End If
    Next

    Rick


    "Randy" <ranbar@pipeline.com> wrote in message
    news:3a89a410$1@news.devx.com...
    >
    >
    > Inside the Validate event ActiveControl is still the control firing

    Validate.
    > How do you get the name of the control that WILL be active once Validate
    > exits?




  3. #3
    Randy Guest

    Re: Find name of next control from Validate


    Rick,

    Actually, I am executing code in a validate event that branches based upon
    which command button was clicked. I guess I can get this if I subclass WM_KILLFOCUS,
    which gives you the handle of the control about to receive the focus, but
    i'd rather avoid that method.

    Randy


    "Rick Rothstein" <rick_newsgroup@email.com> wrote:
    >If by the next control you mean the one that is next in the Tab order, then
    >consider this
    >
    > Dim cntl As Control
    > ......
    > ......
    > For Each cntl In Controls
    > If Screen.ActiveControl.TabIndex + 1 _
    > = cntl.TabIndex Then
    > Debug.Print cntl.Name & " is the next control"
    > End If
    > Next
    >
    >Rick
    >
    >
    >"Randy" <ranbar@pipeline.com> wrote in message
    >news:3a89a410$1@news.devx.com...
    >>
    >>
    >> Inside the Validate event ActiveControl is still the control firing

    >Validate.
    >> How do you get the name of the control that WILL be active once Validate
    >> exits?

    >
    >



  4. #4
    Kenny Acock Guest

    Re: Find name of next control from Validate


    Randy,

    >Actually, I am executing code in a validate event that branches based upon
    >which command button was clicked. I guess I can get this if I subclass WM_KILLFOCUS,
    >which gives you the handle of the control about to receive the focus, but
    >i'd rather avoid that method.


    Sad news. That may be your only solution.

    Either the Validate event fires before WM_KILLFOCUS, or VB has simply chosen
    not to give this information away. Either way it looks like subclassing
    is your answer.

    --Kenny

  5. #5
    Kenny Acock Guest

    Re: Find name of next control from Validate


    Randy,

    Ignore my previous post. There is a way you can cheat. The LostFocus event
    will fire after the control has lost focus, which means you can use the ActiveControl
    property. You can use the Validate event to decide what to do, then use
    the LostFocus event to do it.

    --Kenny

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center