Form loading

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

    Form loading

    in the following load event my form becomes visible before I have set its
    position. I'd like to set its position and then have the form become
    visible. In other words I'd like to process the code in the sub form top to
    bottom. Is there a setting for the project that I need to activate to
    process like this?
    Private Sub Form1_Load(ByVa l sender As Object, ByVal e As System.EventArg s)
    Handles MyBase.Load
    Me.Left = SystemInformati on.WorkingArea. Width - Me.Width
    Me.Top = SystemInformati on.WorkingArea. Height - Me.Height
    fMain.CurrentDa te.Text = CStr(Now())
    f.Close()
    Me.Visible = True
    Me.ShowInTaskba r = True
    End Sub


  • Fergus Cooney

    #2
    Re: Form loading

    Hi Nathan,

    It surprises me that your Form is showing within Load, I expect it to stay
    hidden until Load returns. Also, there should be no need for Me.Visible =
    True.

    Anyway.

    If you open up the "Windows Form Designer generated code" region, you'll
    see Public Sub New(). Add your position-setting code after the call to
    InitializeCompo nent().

    Regards,
    Fergus


    Comment

    • Chris Dunaway

      #3
      Re: Form loading

      "Nathan Carroll" <thelosthorizon @Bhutan.com> wrote in
      news:#90L28sgDH A.4088@tk2msftn gp13.phx.gbl:
      [color=blue]
      > in the following load event my form becomes visible before I have set
      > its position. I'd like to set its position and then have the form
      > become visible. In other words I'd like to process the code in the
      >[/color]

      In addition to what Fergus said, it appears that you are trying to center
      the form on the screen. If that is the case, then why not set the forms
      StartPosition property to CenterScreen and save yourself the trouble?

      Chris

      Comment

      Working...