2013-07-03 1 views
-1

나는 같은 일부 winform을 설정 한방지 다른 윈폼은

윈폼

mainWinform 
winform1 
winform2 
winform3 ... 

winform1, winform2winform3을 목록 상속되는 mainWinform 디자인을 가지고 :

maximizeBox = false 
FormBorderStyle to Sizable 

winform2 :

maximizeBox = true 
FormBorderStyle to fixed 

내가 mainWinform에서 상속하고 있기 때문에 심지어 winform1maximizeBox = falseFormBorderStyle to Sizable로 설정 한 mainWinform를 설정하여 maximizeBox = true, FormBorderStyle to Sizable에 모든 winform을 설정할 수있는 방법이 무엇입니까?

+0

은 단순히 이러한 속성을 오버라이드 (override)됩니다'mainWinform', 다른 파생 된 형태의 생성자에서 속성을 설정 필요한 경우. –

+0

@KingKing OP의 질문에 대해서는 완전히 완전하게 대답하지 않습니다. 파생 된 양식의 우선 적용을 막을 수있는 방법이 있는지 물어보고 있습니다. –

답변

1

, 당신은 부모 폼 클래스에 OnStyleChanged을 재정의 할 시도 할 수 있습니다 :

protected override void OnStyleChanged(EventArgs e) 
{ 
    if (this.MaximizeBox!=true) this.MaximizeBox = true; 
    base.OnStyleChanged(e); 
} 
0

상속 된 form s의 생성자에서 이러한 속성을 설정해야합니다. 예 :

public winform 
{ 
    //in this way you can inherit parent form properties and set them to child form 
    this.MaximizeBox = base.MaximizeBox; 
    this.FormBorderStyle = base.FormBorderStyle; 
    //or if you want to set it something else, then do like this 
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; 
} 

값은 필요에 따라 변경할 수 있습니다. 하지만 생성자에 코드를 넣어야합니다. 재정의 부모 설정에서 상속 된 형태를 방지하기 위해