프로그래밍/c# & VB 등

자식 form이 열려있는지 확인하는 코드

낼은어떻게 2023. 2. 3. 21:53
1
2
3
4
5
6
7
8
9
10
11
12
 private Form IsFormAlreadyOpen(Type FormType)
        {
            foreach (Form OpenForm in Application.OpenForms)
            {
                if (OpenForm.GetType() == FormType)
                    return OpenForm;
            }
 
            return null;
        }
 
 
cs

 

 

 

1
2
3
4
if ((IsFormAlreadyOpen(typeof(Form2)) != null))
{
   //코
}
cs