把项目名选出来放到DataTable后,
循环DataTable,一个一个地插到comboBox
如:
comboBox1.Items.Add(”项目名“);
即可
循环DataTable,一个一个地插到comboBox
如:
comboBox1.Items.Add(”项目名“);
即可
解决方案 »
- 使用页面缓存,缓存实例化对象是否有必要?
- 如何给from加圆交背景?
- 我的VS2005 的 workflow fundation 设计器如何和其它的不同!已经装了最新的了。??急急急,请看详细
- 请教个问题,为什么老是提示这个错误??
- 如何直接在内存中对Bitmap图片进行裁剪
- 到哪可以找到C#面试的题目啊?
- 请问有没有人可以告诉我,如何设主窗体和子窗体呀,我刚刚学的,知道的朋友们,可不可以告诉我呀,要详细点呀,我很笨的呀
- 在WINFORM中,怎样对数据表汇总
- 关于SQL更新的一个问题,进来看看
- C# struct有字段是引用类型的,这样效率会好吗?我应该用类吗?
- ((LinkButton)e.CommandSource).Text该怎样查帮助?
- 关于在数据库中存储和读取图片(Access)
foreach(DataRow dr in dt)
{
radioButton rb=new radioButton();
rb.Text=项目名;
Form1.Controls.Add(rb);
}
可以实现你的问题二
ddataset = new DataSet();
dadapter.Fill(ddataset,"dtable");
这样你的项目名就在 dtable 中了
怎么定义它,或是引用什么命名空间?
你在winform下面
根本就不用管它属于哪个命名空间
因为默认已经添加了该命名空间
没有仔细看
shi-----------RadioButton
{
sqlConnection1.Open();
sqlCommand1.CommandText = "Select 维修项目名 from JJGZ_XiangMu";
SqlDataReader dReader = sqlCommand1.ExecuteReader();
while (dReader.Read())
{
RadioButton rb=new RadioButton();
rb.Text=dReader["维修项目名"].ToString();
this.Controls.Add(rb);
}
dReader.Close();
}
我搞定这个了,但是只能添加一个控件,再看看。
rb.Text=dReader["维修项目名"].ToString();
this.Controls.Add(rb);
//的后面加了这句
MessageBox.Show(rb.Text);
//发现每个"维修项目名“都可以显示。窗体上只能显示一个,被覆盖了?还是定义rb的问题?
rb.Location= new System.Drawing.Point(xyz+=60, 0);//在循环体内,搞定!
RadioButton rb=new RadioButton();
rb.Text=dReader["维修项目名"].ToString();
this.Controls.Add(rb);
控件的名字都是一样的呀!!你可以加一个count的控制一下不可以嘛??
int y=0;
int count;rb.Name = "radioBox"+count++;
rb.Location= new System.Drawing.Point(x,y);
this.Controls.Add(rb);
MessageBox.Show(rb.Name);
x+=160; //160为各个RadioButton的列间距
if(x>1000) //一行显示完后换下一行
y+=100;
x=x%1000; //这个1000大概可以定下来在窗体上一行上显示几个
y=y%2000;
while(count)
{
if(radioBox