Donate

Did you find articles useful? Please make a donation

Windows uygulamalarında form konum ve boyut ayarları

Bir uygulamanın en son kapatıldığı konum ve boyutlarda açılması için

  • Önce uygulamanızın özelliklerinden Settings sekmesine gelin, Location ve Size isimlerinde iki değişken tanımlayın

  • Form kapandığında bu ayarları kaydetmesi için Form_Closed event ine aşağıdaki kodları yazın
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
Settings.Default.Location = new Point(this.Left, this.Top);
Settings.Default.Size = new Size(this.Width, this.Height);
Settings.Default.Save();
}
  • Form tekrar açıldığında kaydedilen ayarlarla açılabilmesi için Form_Load event ine aşağıdaki kodları yazın
private void Form1_Load(object sender, EventArgs e)
{
this.Left = Settings.Default.Location.X;
this.Top= Settings.Default.Location.Y;
this.Width = Settings.Default.Size.Width;
this.Height = Settings.Default.Size.Height;
}

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>