How to set start position for form in C#

This article show how to set form start position when form is starting up in visual studio. To do this, i would like to show you two ways by write code on event form load and set it manually in form properties.
Set form start position without coding

  1. Right click on the form --> Choose Properties 
  2. In Properties Panel, In StartPosition --> Choose CenterScreen
set form start position as CenterScreen
Your window form will appear as center of your computer screen. You can do it by other way as below:
Set form start position with coding on event form load

privatevoid CustomerOrder_Load(object sender, EventArgs e)
{
    //set form statewindows(normal,maximized,minimized)
    this.WindowState = FormWindowState.Normal;
    //set form start position on the center of screen
    this.StartPosition = FormStartPosition.CenterScreen;
    //set size for form
    this.Size = new Size(500,450);
   //set form border style
   this.FormBorderStyle = FormBorderStyle.FixedSingle;
}

Done ....hope you fun with it...:) 
       
    How to set start position for form in C# How to set start position for form in C# Reviewed by BeiLover on 5:07 PM Rating: 5

    No comments:

    Powered by Blogger.