C#/Layout 및 델리게이트
C# 폼크기 및 위치 저장(Properties.Settings 이용)
Link2Me
2015. 12. 3. 00:20
C# 에서 자식창을 띄울때 창의 마지막 크기와 위치를 저장하고 싶을 때
먼저, 솔루션 탐색기에서 Properties 를 선택하고 Settings.settings 를 더블 클릭한다.
아래 그림처럼 이름과 형식을 설정해준다.
이제 이벤트를 생성하여 코드를 추가한다.
private void WBrowser_FormClosing(object sender, FormClosingEventArgs e)
{
Properties.Settings.Default.FormSize = this.Size;
Properties.Settings.Default.Location = this.Location;
Properties.Settings.Default.Save();
}
private void WBrowser_Load(object sender, EventArgs e)
{
this.Size = Properties.Settings.Default.FormSize;
this.Location = Properties.Settings.Default.Location;
}
창의 최소 사이즈는 속성에서 설정해준다.
728x90