将控件添加到面板,控件不会';不再显示c#
我有一个文本框(textBox1)和面板(Panel1),我有这样的代码将控件添加到面板,控件不会';不再显示c#,c#,C#,我有一个文本框(textBox1)和面板(Panel1),我有这样的代码 Panel1.Controls.Add(textBox1) 所以当我运行它时,我再也看不到文本框了,如果我这样做,我可以看到文本框 textBox1.Location = Panel1.Location 有人能告诉我问题出在哪里吗?我相信您无法看到文本框的原因与面板的属性有关。尝试将AutoSize属性设置为true,将AutoSizeMode属性设置为growthandshrink,我相信无法看到文本框的原因与面板
Panel1.Controls.Add(textBox1)
所以当我运行它时,我再也看不到文本框了,如果我这样做,我可以看到文本框
textBox1.Location = Panel1.Location
有人能告诉我问题出在哪里吗?我相信您无法看到文本框的原因与面板的属性有关。尝试将AutoSize属性设置为
true
,将AutoSizeMode属性设置为growthandshrink
,我相信无法看到文本框的原因与面板的属性有关。当文本框(或任何控件)是面板的一部分时,请尝试将AutoSize属性设置为true
,将AutoSizeMode属性设置为growthandshrink
,面板左上角为点(0.0)
因此,当textBox1.Location=Panel1.Location时,该文本框可能会从面板中消失
试试这样吧/
//
// panel1
//
this.panel1.Controls.Add(this.textBox1);
this.panel1.Location = new System.Drawing.Point(59, 27);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(193, 176);
this.panel1.TabIndex = 1;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(0, 0);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 0;
当文本框(或任何控件)是面板的一部分时,面板的左上角为点(0.0)
因此,当textBox1.Location=Panel1.Location时,该文本框可能会从面板中消失
试试这样吧/
//
// panel1
//
this.panel1.Controls.Add(this.textBox1);
this.panel1.Location = new System.Drawing.Point(59, 27);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(193, 176);
this.panel1.TabIndex = 1;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(0, 0);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 0;
您必须在
面板1
中找到文本框1
。如果设置textBox1.Location=new Point(0,0)
,则会在面板左上角看到文本框。您必须在Panel1
中找到textBox1
。如果设置textBox1.Location=new Point(0,0)
,则会在面板的左上角看到文本框。