Setting focus inside a Panel

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jp2express

    Setting focus inside a Panel

    I have several applications that use panels as screens, but I can *not* seem
    to set the focus for a Textbox.

    Panel1.BringToF ront()
    Panel1_Textbox. Focus()
    ' do something with a control on Panel1
    Panel2.BringToF ront()
    Panel2_Textbox. Focus()
    ' do something with a control on Panel2

    When the applications are running, I can almost see the Textbox controls
    receiving focus for an instant, then Nothing has focus!

    How do I set the Focus on the Textbox controls ... and have it STAY there?


  • kimiraikkonen

    #2
    Re: Setting focus inside a Panel

    On Mar 21, 10:18 pm, "jp2express " <useF...@joeswe lding.bizwrote:
    I have several applications that use panels as screens, but I can *not* seem
    to set the focus for a Textbox.
    >
    Panel1.BringToF ront()
    Panel1_Textbox. Focus()
    ' do something with a control on Panel1
    Panel2.BringToF ront()
    Panel2_Textbox. Focus()
    ' do something with a control on Panel2
    >
    When the applications are running, I can almost see the Textbox controls
    receiving focus for an instant, then Nothing has focus!
    >
    How do I set the Focus on the Textbox controls ... and have it STAY there?
    Normally,
    textbox.focus gives focus. But if you lose focus for some reason and
    still you want your textbox has the focus then you should:

    Private Sub TextBox1_lostfo cus(ByVal sender As System.Object, ByVal e
    As System.EventArg s) Handles_ TextBox1.LostFo cus

    TextBox1.Focus( )

    End Sub

    Therefore, when you textbox loses focus, it re-gains the focus.

    Hope this helps.

    Comment

    • =?Utf-8?B?anAybXNmdA==?=

      #3
      Re: Setting focus inside a Panel

      Interesting trick! I will certainly give it a try. Thanks!

      "kimiraikko nen" wrote:
      On Mar 21, 10:18 pm, "jp2express " <useF...@joeswe lding.bizwrote:
      I have several applications that use panels as screens, but I can *not* seem
      to set the focus for a Textbox.

      Panel1.BringToF ront()
      Panel1_Textbox. Focus()
      ' do something with a control on Panel1
      Panel2.BringToF ront()
      Panel2_Textbox. Focus()
      ' do something with a control on Panel2

      When the applications are running, I can almost see the Textbox controls
      receiving focus for an instant, then Nothing has focus!

      How do I set the Focus on the Textbox controls ... and have it STAY there?
      >
      Normally,
      textbox.focus gives focus. But if you lose focus for some reason and
      still you want your textbox has the focus then you should:
      >
      Private Sub TextBox1_lostfo cus(ByVal sender As System.Object, ByVal e
      As System.EventArg s) Handles_ TextBox1.LostFo cus
      >
      TextBox1.Focus( )
      >
      End Sub
      >
      Therefore, when you textbox loses focus, it re-gains the focus.
      >
      Hope this helps.
      >

      Comment

      • =?Utf-8?B?VGVycnk=?=

        #4
        Re: Setting focus inside a Panel

        Looks to me like such a "trick" would cause you to be in a loop with it
        impossible to get "out of" the textbox!
        --
        Terry


        "kimiraikko nen" wrote:
        On Mar 21, 10:18 pm, "jp2express " <useF...@joeswe lding.bizwrote:
        I have several applications that use panels as screens, but I can *not* seem
        to set the focus for a Textbox.

        Panel1.BringToF ront()
        Panel1_Textbox. Focus()
        ' do something with a control on Panel1
        Panel2.BringToF ront()
        Panel2_Textbox. Focus()
        ' do something with a control on Panel2

        When the applications are running, I can almost see the Textbox controls
        receiving focus for an instant, then Nothing has focus!

        How do I set the Focus on the Textbox controls ... and have it STAY there?
        >
        Normally,
        textbox.focus gives focus. But if you lose focus for some reason and
        still you want your textbox has the focus then you should:
        >
        Private Sub TextBox1_lostfo cus(ByVal sender As System.Object, ByVal e
        As System.EventArg s) Handles_ TextBox1.LostFo cus
        >
        TextBox1.Focus( )
        >
        End Sub
        >
        Therefore, when you textbox loses focus, it re-gains the focus.
        >
        Hope this helps.
        >

        Comment

        Working...