find out in MDI-Form which Control has the focus

hi,

i have a MDI-Form. I want to find out, which control (Textbox, Textfield) currently  has got the focus. these controls may be in a TabControl.

bye



Answer this question

find out in MDI-Form which Control has the focus

  • lela_dd

    hi Paul,

    thanks for your answer; i guessed that i have to traverse so as you described. Isnt there a easier way Sad

    bye

  • NiroViji

    Hi,

    Aside from the ActiveControl property, I am not aware of an easier way to do this. Big Smile





    cheers,

    Paul June A. Domag


  • tk18

    Hi,

    You can do that by looking in the ActiveControl property of the form. It contains the control that has the focus. Check if the type is one of the container controls (panel, groupbox or tab) if it is then also look at its active control property or traverse all of its contained controls to see if what control has focus...




    cheers,

    Paul June A. Domag


  • DanielSilva

    In your Mdi container form, you can do this:

    private Control GetActiveControl() {
       Form f = this.ActiveMdiChild;
       if( f != null ) {
          return f.ActiveControl;  // This could be null.
       }
    }



  • ZnZn

    Note if the ActiveControl is a ContainerControl you may have to dig down a level to find out the actual "Focused" control.
  • find out in MDI-Form which Control has the focus