How to set default focus on popup

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shahjeet297
    New Member
    • Sep 2010
    • 4

    #1

    How to set default focus on popup

    Hi,
    I am able set default focus on user control when it's loaded. using Loaded event. But the visual's are still missing?

    Can anyone help?
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    What do you mean by "the visual's are still missing?"

    ?

    Your controls aren't showing up on your form? Please post some code so we can help debug the problem.

    Thanks!

    Comment

    • shahjeet297
      New Member
      • Sep 2010
      • 4

      #3
      btnBrowse.Focus () in onLoaded event handler. when i press enter dialog opens but i can't seen where the focus is on the screen dotted rectangle not shown.

      Comment

      • GaryTexmo
        Recognized Expert Top Contributor
        • Jul 2009
        • 1501

        #4
        Ah ok, so I did some digging around and it seems this behaves strangely. Have a look at this thread...



        It looks like the Focus method doesn't work during the load part of a form, but does later. I couldn't seem to get it to work unless I put my button's focus on the event of another button's click. I speculated you could also trigger a timer on a form load event to set the focus after a few seconds, but I didn't try it... seems wishy washy anyway.

        What did work was putting this in the form's load event...

        Code:
        this.ActiveControl = theButton
        This seemed to work for me... I have no idea why it's different than the focus call. Alternatively you could set up the tab indexes on your form so that the appropriate button had an index of zero.

        Hope that helps!

        Comment

        Working...