private void button1_Click(object sender, EventArgs e)
{ CustomNameForm cnForm = new CustomNameForm();
DialogResult lFormResult = cnForm.ShowDialog();
if (lFormResult == DialogResult.OK)
{
txtCustomName.Text = cnForm.sSName;
this.listBox1.Items.Clear(); //清空listbox
string gCname = custom_m.GetCname(txtCustomName.Text);
string gEname = custom_m.GetEname(txtCustomName.Text); MyItemlist obj1 = new MyItemlist();
string[] arrCName = gCname.Split(',');
string[] arrEName = gEname.Split(',');
for (int i = 0; i < arrEName.Length; i++)
{
obj1.Text = arrCName[i].ToString();
obj1.Value = arrEName[i].ToString();
listBox1.Items.Add(obj1);
foreach (Control ctl in this.Controls)
{
if (ctl is CheckBox)
{
if (((CheckBox)ctl).Text == obj1.Text)
{
((CheckBox)ctl).Checked = true;
}
}
}
}
}
我想按那个button把刚刚已选的checkbox改为未选中,怎么弄啊?新手,大家帮忙一下,谢谢!
{ CustomNameForm cnForm = new CustomNameForm();
DialogResult lFormResult = cnForm.ShowDialog();
if (lFormResult == DialogResult.OK)
{
txtCustomName.Text = cnForm.sSName;
this.listBox1.Items.Clear(); //清空listbox
string gCname = custom_m.GetCname(txtCustomName.Text);
string gEname = custom_m.GetEname(txtCustomName.Text); MyItemlist obj1 = new MyItemlist();
string[] arrCName = gCname.Split(',');
string[] arrEName = gEname.Split(',');
for (int i = 0; i < arrEName.Length; i++)
{
obj1.Text = arrCName[i].ToString();
obj1.Value = arrEName[i].ToString();
listBox1.Items.Add(obj1);
foreach (Control ctl in this.Controls)
{
if (ctl is CheckBox)
{
if (((CheckBox)ctl).Text == obj1.Text)
{
((CheckBox)ctl).Checked = true;
}
}
}
}
}
我想按那个button把刚刚已选的checkbox改为未选中,怎么弄啊?新手,大家帮忙一下,谢谢!
{
if (ctl is CheckBox)
{
if (((CheckBox)ctl).Text == obj1.Text)
{
((CheckBox)ctl).Checked = false;
}
}
}
取消选中 为 false直接赋值使用,一试便知