62,046
社区成员
发帖
与我相关
我的任务
分享
for(int i = 1,i<49,i++){
strLabelName = "label" + i;
Label _label = this.FindControl(strLabelName);
_label.Text = *;
}
\\WinForm把this.FindControl 改成this.Controls [strLabelName] as Label;
TDBOperator db = null;
try
{
db = TDBOperatorFactory.GetDBOperator(comFunction.getDBLink());
//打开数据库连接
db.Open();
System.Data.Common.DbConnection dc = db.getDbConnection();
string[] res = new string[4];
res[1] = "dbo";
//取得全部表名
DataTable dt = dc.GetSchema("Tables");
this.Text = dt.Rows.Count.ToString();
dt.WriteXml("table.xml");
foreach (System.Data.DataRow row in dt.Rows)
{
//取出数据库中系统表外的所有表名
if (row[3].ToString() == "TABLE")
{
listBox1.Items.Add(row[2].ToString());
listBox1.Items.Add("============================");
for (int i = 0; i < 4; i++) res[i] = null;
res[2] = row[2].ToString();
//取得相应表的所有字段
DataTable dtColumns = dc.GetSchema("Columns", res);
foreach (System.Data.DataRow rowColumns in dtColumns.Rows)
{
listBox1.Items.Add(rowColumns[3].ToString());
}
dtColumns.WriteXml(row[2].ToString() + "b.xml");
listBox1.Items.Add("============================");
}
}
}
catch (Exception ex)
{
comMsgBox.showError(ex.Message);
}
finally
{
db.Close();
}
1.foreach (Control c in this.Controls[1].Controls)
{
if (c is Label)
{
Label lbl = (Label)c;
}
}
2.private void GetLabel(Control c)
{
if (c.GetType().Name == "Label")
{
}
else if (c.HasControls())
{
for (int i = 0; i < c.Controls.Count; i++)
{
GetLabel(c.Controls[i]);
}
}
}