DataTable dtl = new DataTable();
dtl.Columns.Add("id");
dtl.Columns.Add("name");
DataRow r = dtl.NewRow();
r[0] = 1;
r[1] = "a";
dtl.Rows.Add(r);
r = dtl.NewRow();
r[0] = 2;
r[1] = "b";
dtl.Rows.Add(r);
r = dtl.NewRow();
r[0] = 3;
r[1] = "c";
dtl.Rows.Add(r); Hashtable ht = new Hashtable();
foreach (Control ctl in Info_groupBox.Controls)
{
if (ctl is TextBox || ctl is RichTextBox)
{
//ctl.Text = reader[col].ToString();
//col++;
ht.Add(ctl.TabIndex.ToString(), ctl);
}
}
//...
foreach(DataRow row in dtl.Rows)
{
TextBox ctl = ht[row[0]] as TextBox;
if (ctl != null)
{
ctl.Text = row[1].ToString();
}
}
大概思路,设置好tabindex,然后遍历Info_groupBox,放到Hashtable中
dtl.Columns.Add("id");
dtl.Columns.Add("name");
DataRow r = dtl.NewRow();
r[0] = 1;
r[1] = "a";
dtl.Rows.Add(r);
r = dtl.NewRow();
r[0] = 2;
r[1] = "b";
dtl.Rows.Add(r);
r = dtl.NewRow();
r[0] = 3;
r[1] = "c";
dtl.Rows.Add(r); Hashtable ht = new Hashtable();
foreach (Control ctl in Info_groupBox.Controls)
{
if (ctl is TextBox || ctl is RichTextBox)
{
//ctl.Text = reader[col].ToString();
//col++;
ht.Add(ctl.TabIndex.ToString(), ctl);
}
}
//...
foreach(DataRow row in dtl.Rows)
{
TextBox ctl = ht[row[0]] as TextBox;
if (ctl != null)
{
ctl.Text = row[1].ToString();
}
}
大概思路,设置好tabindex,然后遍历Info_groupBox,放到Hashtable中
解决方案 »
- C# Winfrom如何编写生成器?
- C#中创建iis 虚拟目录遇到难题(未处理COMException 当文件已存在时,无法创建该文件。异常来自HRESULT:0x800700B7)请大大来帮忙诊断下
- winform中的datagrid中有两个绑定字典表的comboBox列,例如学院和系,如何做到修改学院列后,绑定的系别列也跟随变化
- C# Windows Form 实现折线图或者柱状图 代码示例 怎么写?
- 请帮我解决连接数据库的问题
- 一个简单的问题,希望大家指点一下
- 请问在VS2005中,进行单元测试,总是出现有“单元测试适配器引发异常: System.IO.FileNotFoundException”的错误,望明白人指点一下,谢
- 俄文显示
- 谁知道关于《Developing Visual Studio .NET Macros and Add-Ins》这本书的下载地址
- 我是一个初学者,是否可以学vs.net,如果可以,是学vb.net,vc.net还是c#?
- winform 中怎么保存这个图
- 第一次出现的AUTOGET.exe类型的异常
把textbox的tag设置为列名,用列名(tag)索引。