Form loading

  • Thread starter Thread starter Nathan Carroll
  • Start date Start date
N

Nathan Carroll

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(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Me.Left = SystemInformation.WorkingArea.Width - Me.Width
Me.Top = SystemInformation.WorkingArea.Height - Me.Height
fMain.CurrentDate.Text = CStr(Now())
f.Close()
Me.Visible = True
Me.ShowInTaskbar = True
End Sub
 
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
InitializeComponent().

Regards,
Fergus
 
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

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
 
Back
Top