2
我想创建一种带有文本框和复选框的4 x 3矩阵。元素是复选框还是文本框取决于数据库中的值。我希望它是动态的。什么是最好的开始?c中的动态控件#
// something like this but I need to fill in each elements of the matrix...
private void CreateSpecificControl(string requestedType)
{
if (requestedType == "CheckBox")
{
CheckBox control1 = new CheckBox();
control1.Click += new EventHandler(chk_CheckedChanged);
//TableLayout panel
layout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25));
layout.Controls.Add(control1);
}
else
{
Label control1 = new Label();
control1.Text = "Not a checkbox";
layout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25));
layout.Controls.Add(control1);
}
}
你能否用更多的细节来更新你的问题,比如你正在谈论什么编程语言/环境,以及关于特定问题的一些背景知识。谢谢。 – 2009-01-13 04:47:31
这是在winform中,我使用TableLayoutPanel与growstyle作为附加。但那样我就无法挑选和选择每个元素。所有元素必须是文本框或复选框。 – 2009-01-13 04:52:06