Hi is it possible to center my form during run-time?and how do i get the dimension of the screen of desktop so that when it runs in different dimension my form will be centered always.I hope someone hears me.
Code: this.StartPosition = FormStartPosition.CenterScreen; Just this will center the form programatically in all resolutions.
in VBnet you can try Code: ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. Me.StartPosition = FormStartPosition.CenterScreen or you can just view "properties" of your form and change the "StartPosition" to "Center Screen"
I wouldn't use primaryscreen, think this may be better: Code: Dim current = Screen.FromControl(Me).WorkingArea Me.Top = current.Top + CInt(current.Height / 2) - (Me.Height / 2) Me.Left = current.Left + CInt(current.Width / 2) - (Me.Width / 2)
My tip is always use the wherewithal of the programming language. .NET wins at many points with the productivity of other languages on the programming world. Isn't good back to the past, programming buttons or do the encapsulated methods manually. Use the .NET for you!