C# 최상위 매인폼을 가져오는 방법. (How to get the top-level main form.)
페이지 정보
본문
외부 모듈 또는 하위 폼이나 유저 컨트롤에서 최상위 폼을 가져오는 방법입니다. 엔지엠의 경우 최상위 매인폼은 IMainView를 상속 받고 있습니다. 만약, 타입으로 체크할 수 없으면 Form의 Parent가 null인지 체크하면 동일한 효과를 낼 수 있습니다.
/// <summary>
/// 최상위 매인뷰를 가져옵니다.
/// </summary>
/// <returns><see cref="NGM.Interface.IMainView"/></returns>
public static NGM.Interface.IMainView GetMainView()
{
var forms = Application.OpenForms;
foreach (var form in forms)
{
if (form is NGM.Interface.IMainView)
return form as NGM.Interface.IMainView;
}
return null;
}
개발자에게 후원하기
추천, 구독, 홍보 꼭~ 부탁드립니다.
여러분의 후원이 빠른 귀농을 가능하게 해줍니다~ 답답한 도시를 벗어나 귀농하고 싶은 개발자~
감사합니다~
추천0 비추천0
- 이전글윈도우즈의 버전이 7인지 체크하는 방법. (How to check if the version of Windows is 7.) 21.06.09
- 다음글윈폼 이미지를 WPF 이미지로 변환하기. (Converting WinForms Image to WPF Image.) 21.06.07
댓글목록
등록된 댓글이 없습니다.