2017-01-23 1 views
1

영어가 그리 좋지 않습니다.C에서 그룹 박스를 상속하는 방법 #

안녕하세요, 내가 GroupBox에서 상속 한 클래스가 있고 다형성을 사용하고 디버거에서 모두 corrent가 표시되지만 컴파일 후에 아무 것도 볼 수 없습니다 ... 다음과 같은 스크린 샷이 있으며 어떻게 표시되어야합니까? .

grid = new Grid.KierownikGrid(); 
SetGrid(); 

private void SetGrid() 
{ 
    grid.Location = new System.Drawing.Point(1, 0); 
    grid.Size = new System.Drawing.Size(10,10); 
    grid.TabIndex = 10; 
    grid.TabStop = false; 
    grid.Text = ""; 
} 

public class KierownikGrid : GroupBox 
{ 
    RadioButton addUsers; 
    RadioButton deleteUsers; 
    RadioButton troubles; 

    public KierownikGrid() 
     :base() 
    { 
     Inicjacja(); 
    } 

    protected void Inicjacja() 
    { 
     this.Controls.Add(addUsers = new RadioButton()); 
     this.Controls.Add(deleteUsers = new RadioButton()); 
     this.Controls.Add(troubles = new RadioButton()); 

     this.addUsers.AutoSize = true; 
     this.addUsers.Checked = true; 
     this.addUsers.Location = new System.Drawing.Point(3, 10); 
     this.addUsers.TabIndex = 0; 
     this.addUsers.TabStop = true; 
     this.addUsers.Text = "Dodaj użytkownika"; 
     this.addUsers.UseVisualStyleBackColor = true; 

     this.deleteUsers.AutoSize = true; 
     this.deleteUsers.Location = new System.Drawing.Point(125, 10); 
     this.deleteUsers.TabIndex = 1; 
     this.deleteUsers.Text = "Usuń użytkownika"; 
     this.deleteUsers.UseVisualStyleBackColor = true; 

     this.troubles.AutoSize = true; 
     this.troubles.Location = new System.Drawing.Point(250, 10); 
     this.troubles.TabIndex = 2; 
     this.troubles.Text = "Problemy"; 
     this.troubles.UseVisualStyleBackColor = true; 

    } 
} 
@BugFinder 이미 폼에 컨트롤을 추가 할 필요가 언급 한 바와 같이

https://i.stack.imgur.com/DFu4t.png https://i.stack.imgur.com/Dqeim.png

+0

그리드를 자식으로 추가 했습니까? – BugFinder

+0

아니요, 아닙니다. 나는 그것을해야합니까 ?? –

+0

잘 보여주는 방법을 어디에서 알 수 있습니까? 어떤 양식을 써야하는지 어떻게 알 수 있습니까? 당신은 그리드에 컨트롤을 추가했지만 폼에 컨트롤로 그리드를 추가한다고 생각하지 않았습니까? – BugFinder

답변

0

.

tutorial이 있습니다.

public class Form1 : System.Windows.Forms.Form 
    { 
     //Controls. 
     private TextBox txtBox = new TextBox(); 
     private Button btnAdd = new Button(); 
     private ListBox lstBox = new ListBox(); 
     private CheckBox chkBox = new CheckBox(); 
     private Label lblCount = new Label(); 

     private void Form1_Load(object sender, EventArgs e) 
     { 
      //Add controls to the form. 
      this.Controls.Add(btnAdd); 
      this.Controls.Add(txtBox); 
      this.Controls.Add(lstBox); 
      this.Controls.Add(chkBox); 
      this.Controls.Add(lblCount); 
     } 
    } 
+0

링크가 죽을 수 있으므로 관련 코드 샘플을 게시하십시오. – Natrium

+0

감사합니다 :) Controls.Add and it works :) –

관련 문제