怎么在winform 里,在chechbox控件里怎么把数据循环出来
怎么在winform 里,在chechbox控件里怎么把数据循环出来有3个checkbox控件,分别是,湖南,杭州,北京,怎么把这3个值循环出来 --------------------编程问答-------------------- 干吗不直接用checklistbox呢? --------------------编程问答-------------------- foreach (Control _SubCheck in this.Controls)
{
if(_SubCheck is CheckBox)
{
MessageBox.Show(_SubCheck.Text);
}
}
--------------------编程问答--------------------
int a,b,c,sum;--------------------编程问答--------------------
if(checkBox1.Checked) a=1;
if(checkBox1.Checked) b=2;
if(checkBox1.Checked) c=4;
sum=a+b+c;
switch(sum)
{
case 0://都没选
case 1://选了第一项
...
case 7://三项都选了
}
推荐 --------------------编程问答--------------------
String str=String.Emty;
foreach(Control _SubCheck in this.Controls)
{
if(_SubCheck is CheckBox)
{
if(str == String.Emty)
{
str = _SubCheck.Text;
}
else
{
str += "," + _SubCheck.Text;
}
}
}
接下来,怎么处理str随便你了。
--------------------编程问答--------------------
--------------------编程问答-------------------- for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
foreach (Control c1 in this.Control)
{
if(c1 is CheckBox && c1.Checked)
{
MessageBox.Show(_SubCheck.Text);
}
}
{
CheckBox vCheckBox = new CheckBox();
vCheckBox.Top = 50;
vCheckBox.Text = i.ToString();
vCheckBox.Left = i * 30;
vCheckBox.AutoSize = true;
this.Controls.Add(vCheckBox);
}
这个数据循环不出呀,我一个一个的循环出来 --------------------编程问答-------------------- 在checkbox里,只要我选择了,才可以把数据输出来呀? --------------------编程问答-------------------- 真不知道是LZ没理解还是我看错了题目? --------------------编程问答-------------------- 到底是取数据还是动态添加控件?
补充:.NET技术 , C#