You can set the Form's StartPosition property to CenterScreen, CenterParent, WindowsDefaultLocation or WindowsDefaultBounds. Alternatively you can use the Location property of the form to set the X and Y coordinates of the form, in which case the StartPosition property should be set to Manual. Most often in your situation I tend to use the StartPosition.CenterParent option.
hey like we see in professional software .........if we press the key "Esc", one form with "Are you sure you want to quit" normally comes...........and we could see when we press "Esc" and when that window comes the form that is behind all turns somewhat gray color right..........how can we do that.............
all i've did right now is: when i press "Esc" form2 comes with exit option........when the form behind is still like that............how can i turn that to completly somewhat gray color?
Rather than using a custom form for this, you can use a MessageBox. Here is a link to the MSDN documentation on this very useful class that can display a message with a set of buttons and an icon. You can use this to determine whether or not the user really wants to quit the application.
EDIT: But if you really want to use your custom form you can use the ShowDialog method instead of the Show method, then check the DialogResult that is returned based on which button the user presses.
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...