Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to step over the next control with GetNextControl(....,true).focus when the next control is not enabled

How to step over the next control with GetNextControl(....,true).focus when the next control is not enabled

Scheduled Pinned Locked Moved C#
tutorialhelpquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fracalifa
    wrote on last edited by
    #1

    Hi all, I have the problem to step over a disabled control with GetNextControl(...,true).Focus to the next enabled one. For example you have 3 textboxes with the tabindex 1,2,3 and a lot of other controls on the form. The focus is on the first textbox, the second one is disabled and I want to step to the third textbox with GetNextControl(...,true). The effect is, that GetNextControl(....,true) jumps to a control for example with tabindex=73 but not to the third one. What can I do to get the (correct) assumed reaction ? tnx Frank

    D realJSOPR W 3 Replies Last reply
    0
    • F fracalifa

      Hi all, I have the problem to step over a disabled control with GetNextControl(...,true).Focus to the next enabled one. For example you have 3 textboxes with the tabindex 1,2,3 and a lot of other controls on the form. The focus is on the first textbox, the second one is disabled and I want to step to the third textbox with GetNextControl(...,true). The effect is, that GetNextControl(....,true) jumps to a control for example with tabindex=73 but not to the third one. What can I do to get the (correct) assumed reaction ? tnx Frank

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #2

      This assumes that you're starting from textBox1 and at least one textBox is enabled (even if only textBox1).

      Control control = textBox1;
      do
      {
      control = GetNextControl(control, true);
      } while (!control.Enabled);
      control.Focus();

      Dave
      BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
      Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

      F 1 Reply Last reply
      0
      • F fracalifa

        Hi all, I have the problem to step over a disabled control with GetNextControl(...,true).Focus to the next enabled one. For example you have 3 textboxes with the tabindex 1,2,3 and a lot of other controls on the form. The focus is on the first textbox, the second one is disabled and I want to step to the third textbox with GetNextControl(...,true). The effect is, that GetNextControl(....,true) jumps to a control for example with tabindex=73 but not to the third one. What can I do to get the (correct) assumed reaction ? tnx Frank

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #3

        Well, you could do something like this:

        Control ctrl = GetNextControl(...);
        if (ctrl.Enabled)
        {
        // ...do something...
        ctrl.Focus();
        }

        I haven't actually tried this, but some variation of it should work.

        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
        -----
        "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

        1 Reply Last reply
        0
        • F fracalifa

          Hi all, I have the problem to step over a disabled control with GetNextControl(...,true).Focus to the next enabled one. For example you have 3 textboxes with the tabindex 1,2,3 and a lot of other controls on the form. The focus is on the first textbox, the second one is disabled and I want to step to the third textbox with GetNextControl(...,true). The effect is, that GetNextControl(....,true) jumps to a control for example with tabindex=73 but not to the third one. What can I do to get the (correct) assumed reaction ? tnx Frank

          W Offline
          W Offline
          Wendelius
          wrote on last edited by
          #4

          Also you could perhaps simply use SelectNextControl[^] without a loop, like:

          textBox1.SelectNextControl(textBox1, true, true, true, true)

          The need to optimize rises from a bad design.My articles[^]

          1 Reply Last reply
          0
          • D DaveyM69

            This assumes that you're starting from textBox1 and at least one textBox is enabled (even if only textBox1).

            Control control = textBox1;
            do
            {
            control = GetNextControl(control, true);
            } while (!control.Enabled);
            control.Focus();

            Dave
            BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
            Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

            F Offline
            F Offline
            fracalifa
            wrote on last edited by
            #5

            Great, that's what I'm looking for ? Tnx Frank

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups