Form Appear

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tigger
    New Member
    • May 2007
    • 37

    #1

    Form Appear

    Hi

    I have a form called Form1. When Form1 loads, another form, Form2, will appear. However, i want Form2 to appear in front of Form1. I tried doing the following but it doesn't seem to work. Form 2 still appear behind Form1.


    Code:
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
            Form2.Show()
            Form2.BringToFront()
    
    End Sub
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Question moved to .NET Forum.

    Comment

    • balabaster
      Recognized Expert Contributor
      • Mar 2007
      • 798

      #3
      Originally posted by tigger
      Hi

      I have a form called Form1. When Form1 loads, another form, Form2, will appear. However, i want Form2 to appear in front of Form1. I tried doing the following but it doesn't seem to work. Form 2 still appear behind Form1.


      Code:
      Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       
      Form2.Show()
      Form2.BringToFront()
       
      End Sub
      This appears to work on my system...

      Code:
       Public Class Form1 
        Private Sub Loaded(ByVal sender As Object, ByVal e As System.EventArgs) _
        Handles MyBase.Load
      	Dim oFrm As Form = New Form2
      	oFrm.Show(Me)
        End Sub
      End Class
      Then in your splash screen (I'm assuming that's what you're using it for), you can have a timer to auto-close it after a period.

      Comment

      • tigger
        New Member
        • May 2007
        • 37

        #4
        Originally posted by balabaster
        This appears to work on my system...

        Code:
         Public Class Form1 
          Private Sub Loaded(ByVal sender As Object, ByVal e As System.EventArgs) _
          Handles MyBase.Load
        	Dim oFrm As Form = New Form2
        	oFrm.Show(Me)
          End Sub
        End Class
        Then in your splash screen (I'm assuming that's what you're using it for), you can have a timer to auto-close it after a period.

        The code works, thanks. However, i have some problem with focusing it. Even though my Form2 appears in front of my Form1, the form is grayed. I need to click on the form, then the focus is on the textbox in the form. I tried 'Form2.nameText Box.Focus()' in the load event but it doesnt work. How do i make the focus go to text box once Form2 loads?

        Comment

        • none
          New Member
          • Nov 2007
          • 3

          #5
          could you try on form2 load just textbox.focus?

          Comment

          • tigger
            New Member
            • May 2007
            • 37

            #6
            Originally posted by none
            could you try on form2 load just textbox.focus?
            I tried but it doesn't work. I also put it in my Form1 but still, the textbox is not focused.

            Comment

            • Shashi Sadasivan
              Recognized Expert Top Contributor
              • Aug 2007
              • 1435

              #7
              Could you please confirm that the Enabled Property of Form2 is set to true?

              Comment

              • tigger
                New Member
                • May 2007
                • 37

                #8
                Originally posted by Shashi Sadasivan
                Could you please confirm that the Enabled Property of Form2 is set to true?
                It's already set to true. I've already managed to solve it. Thanks. I used oFrm.ShowDialog (Me) instead and it works.

                Comment

                Working...