본문 바로가기
C# 언어

C# Windows Forms 항상 닫히지 않게 하기

by treeCoder 2021. 9. 19.

C#에서 Winform으로 만든 프로그램의 창이 항상 열려져 있게 하는 방법이다.

 

아래와 같이 Form을 초기화하는 곳 아래에 같은 Source code 로 작성하여 놓는다.

        public Form1()
        {
            InitializeComponent();
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.TopMost = true;
        }

참고한 곳은 Stack overflow 이다.

https://stackoverflow.com/questions/3025923/disabling-minimize-maximize-on-winform

 

Disabling Minimize & Maximize On WinForm?

WinForms have those three boxes in the upper right hand corner that minimize, maximize, and close the form. What I want to be able to do is to remove the minimize and maximize, while keeping the c...

stackoverflow.com

더하여서 this.TopMost = true 를 추가하는 것이 더 좋을 것 같다.

 

결과적으로 아래의 코드 3줄이 필요하다.

 

      this.MaximizeBox = false;

      this.MinimizeBox = false;

      this.TopMost = true 

 

댓글