各位前辈: 小弟想做一个容器控件继承Pan控件,增加新属性[相关表],然后想跟据[相关表]自动在容器中创建表中各字段控件.
但以下自动创建代码我不知道写在哪里,在OnCreateControl,OnPaint中,执行时[相关表]为空,就不能创建.
System.Int32 i = 0;
foreach (System.Data.DataColumn col in this.相关表.Columns)
{
i += 1;
ComboBox a = new ComboBox();
a.Name = col.ColumnName;
a.Location = new System.Drawing.Point(0, i * a.Height);
this.Controls.Add(a);
} 请高手赐教,谢谢!
但以下自动创建代码我不知道写在哪里,在OnCreateControl,OnPaint中,执行时[相关表]为空,就不能创建.
System.Int32 i = 0;
foreach (System.Data.DataColumn col in this.相关表.Columns)
{
i += 1;
ComboBox a = new ComboBox();
a.Name = col.ColumnName;
a.Location = new System.Drawing.Point(0, i * a.Height);
this.Controls.Add(a);
} 请高手赐教,谢谢!
也就不会创建啊。
private DataTable m_bindtable;public DataTable BindTable
{
get{return m_bindtable;}
set
{
m_bindtable = value;
Bind();
}
}System.Int32 i = 0;
private void Bind()
{
foreach (System.Data.DataColumn col in this.相关表.Columns)
{
i += 1;
ComboBox a = new ComboBox();
a.Name = col.ColumnName;
a.Location = new System.Drawing.Point(0, i * a.Height);
this.Controls.Add(a);
} }