2017-10-25 4 views
0

나는 내가 InitializeComponent에서 호출하고있는 오버라이드 메소드를 가지고있다.InitializeComponent가 폼 디자이너 코드를 변경하는 것을 멈추는 방법?

는 는
public class ComponentResourceManager2 : System.ComponentModel.ComponentResourceManager 

내 문제는 방법은 시스템 하나

System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(); 

예를 사용하도록 내가 DesignerForm에서 메소드의 InitializeComponent 변화 뭔가를 변경할 때마다입니다 :이

private void InitializeComponent() 
    { 
     ComponentResourceManager2 resources = new ComponentResourceManager2(typeof(Form1)); 
     this.directDrawViewer1 = new MyOwn.Imaging.Components.DirectDrawViewer(); 
     this.speedButton1 = new MyOwn.Components.SpeedButton(); 
     ... 
필요

하지만 내가 뭔가를 바꿀 때마다 다시 다음과 같이 진행됩니다.

private void InitializeComponent() 
    { 
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); 
     this.directDrawViewer1 = new MyOwn.Imaging.Components.DirectDrawViewer(); 
     this.speedButton1 = new MyOwn.Components.SpeedButton(); 

무언가가 변경 될 때마다 초기화하지 않고 InitializeComponent에서 내 메서드를 사용하도록 만들 수 있습니까?

+0

디자이너는 initializecomponent 본문을 쓸 것으로 예상됩니다. 다른 곳에서 개체를 만들려고 할 수 있습니다. initializecomponent 호출 직후 형태의 ctor. 작동합니까? –

+0

사실, 내 재정의 메서드는 CultureInfo 리소스를 선택하는 방법을 변경합니다 .ApplyResourcers() 있도록 내 레이블, 단추 정보를 추출하려면 오른쪽 resx 파일을 ... 그래서 InitializeComponent 내부에이 필요합니다. 또는 InitializeComponent 외부에서 다른 방법을 사용할 수 있습니까? – Rafael

답변

1

디자이너 코드를 변경하지 말고 InitializeComponent()가 호출 된 후 Form의 생성자에서 InitializeComponent에서 설정하는 내용을 설정하십시오. 디자이너에서 무언가를 변경할 때마다 Visual Studio에서 디자이너 파일을 다시 생성합니다.

관련 문제