我需要用C#动态生成多个checkbox 而且内容是和后台数据库的某张表相连的.
我现在想先select * from 表名
然后 for(int i=0;i<ds.tables[0].rows.count;i++)
checkbox ab=new checkbox;
下面的代码该怎么写呢
菜鸟提问 在线等
我现在想先select * from 表名
然后 for(int i=0;i<ds.tables[0].rows.count;i++)
checkbox ab=new checkbox;
下面的代码该怎么写呢
菜鸟提问 在线等
解决方案 »
- 搞不定了,改变属性的
- 如何在form2上显示form1的数据表的内容?
- 如何将庞大程序多文件编译!此程序是多功能的学生系统!就是将他的函数分开!
- 单件模式的问题(不用私有化构造函数)
- WinFrom下如何设定DataGrid的某列为可编辑列,其他的列不可编辑
- 请高手帮我看看这段代码
- [急.......]如何在RichTextBox中使输入的关键字变色,并根据输入的内容自动使文本变色??
- WPF ListView动态获取的Item。想在Item上添加image并可以点击
- 关于寸储过程
- 请高手,翻译c#串口的英语文章,不胜感激?
- 添加到tabControl里面的窗体,高度有限制?
- c#如何输出enter键的ascii码值?
这样没错呀
下面想做什么?
ab.Text=ds.Tables[0].Rows[i]["fieldName"].ToString();?
ab.Checked=(bool)ds.Tables[0].Rows[i]["fieldName"];?
checkbox ab=new checkbox();
string str=ds.Tables[0].Rows[i]["fieldName"].ToString();
ab.ID="ab"+i.Tostring();
ab.Text=str
然后下面该怎么写才能使得运行的时候页面出现一个一个的checkbox 而且checkbox的内容是数据库表里某个filename呢?????????????????
你不如改用CheckBoxList控件
不明白不明白 5555555555
checkbox ab=new checkbox();
string str=ds.Tables[0].Rows[i]["fieldName"].ToString();
ab.ID="ab"+i.Tostring();
ab.Text=str
然后this.placeHolder1.Controls.Add(eb);ASP.NET我也是正在初学^-^
private void load(string typename1)
{
List <string> typelist = new List <string>();
typelist = DBconn.selectItem(typename1);
Label[] label = new Label[typelist.Count];
int y1 = 15;
int y2 = 10;
for (int i = 0; i < typelist.Count; i++)
{
if (typelist[i] != "序号")
{
label[i] = new Label();
label[i].Visible = true;
label[i].AutoSize = true;
label[i].Location = new System.Drawing.Point(60, y1);
label[i].Name = typelist[i];
label[i].Size = new System.Drawing.Size(100, 12);
label[i].TabIndex = laltabIndex++;
label[i].Text = typelist[i] + ":"; this.panel1.Controls.Add(label[i]);
textBox[i] = new TextBox();
textBox[i].Text = "fdfd";
textBox[i].Visible = true;
textBox[i].Location = new System.Drawing.Point(150, y2);
textBox[i].Name = typelist[i];
textBox[i].Size = new System.Drawing.Size(160, 21);
textBox[i].TabIndex = txttabIndex++;
this.panel1.Controls.Add(textBox[i]);
y1 = y1 + 40;
y2 = y2 + 40;
}
//
}
我顺便再问个问题 有人知道 <全选> 如何实现吗
遍历PlaceHolder里的checkBox,将所有的选中