这是我刚刚开始练习C#中的多选checkbox控件编得程序,但是编译不过去
Label.Text = "你喜欢的是";
foreach (Control c in this.Controls)
{
if (c!=null )
{
if (c is CheckBox )
{
CheckBox check=(CheckBox)c;
if (check.Checked)
{
Label.Text+=checked.Text;
}
}
}
}
Label.Text = "你喜欢的是";
foreach (Control c in this.Controls)
{
if (c!=null )
{
if (c is CheckBox )
{
CheckBox check=(CheckBox)c;
if (check.Checked)
{
Label.Text+=checked.Text;
}
}
}
}
checked.Text 改成 check.Text
{
if (c is CheckBox )
{
CheckBox check=c as CheckBox;
if(check!=null && check.Checked)
{
Label.Text+=check.Text+",";
}
}
}
}
低价源码出售了,全是自己开发的代码,希望和大家一起交流,集百家之所长,希望能对大家有所帮助。
网店地址:http://shop36675020.taobao.com
{
checkBox check = c as CheckBox
if (check != null && check.checked)
{
Label.Text+=check.Text+",";
}
}
{
label1.Text = "你喜欢的是";
foreach (Control c in this.Controls)//Controls
{
if (c != null)
{
if (c is CheckBox)
{
CheckBox check = (CheckBox)c;
if (check.Checked == true)
{
label1.Text += check.Text;
}
}
}
}
}