如何以编程方式创建面板? [英] how to create panel programmatically ?
本文介绍了如何以编程方式创建面板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在循环中以编程方式创建一个面板,我该怎么做?
我不知道如何为该面板添加背景颜色
i want to create panel one beside another programmatically in loop how can i do that ?
and i dont know how to add background color to that panel
if (!IsPostBack)
{
Panel p = new Panel() {
ToolTip="hy",
Width=23,
Height=55,
};
}
推荐答案
Panel panel = new Panel();
panel.BackColor = System.Drawing.Color.Black;
this.Controls.Add(panel);
,使用Show()方法。
喜欢它:
after you instancead this component, use Show() method.
like it:
Panel p = new Panel();
p.Show();
Panel panel1 = new Panel();
声明后,您可以访问所有属性。
添加面板到你会做这样的事情。
Once it is declared, you can access all the properties.
To add the panel to the form you would do something like this.
myform.controls.add(panel1);
这篇关于如何以编程方式创建面板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文