2017-01-23 9 views
1

私の英語はあまり良くありません。Cでグループボックスを継承する方法

こんにちは、私はここに私はグループボックスから継承し、私はポリモーフィズムを使用したいと私はすべてが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; 

    } 
} 

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

+0

グリッドを何かの子として追加しましたか? – BugFinder

+0

いいえ、私はしませんでした。私はそれを行う必要がありますか? –

+0

それはどこに表示するかを知っていますか?どのような形でそれを置くのかはどのように分かっていますか?コントロールをグリッドに追加しましたが、グリッドをフォームのコントロールとして追加するとは思いませんでしたか? – BugFinder

答えて

0

@BugFinderはすでにフォームにコントロールを追加する必要が述べたように。

これには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とそれは動作します:) –