نوشته شده توسط
hamidtmu
من این کدو توی فرم لودم گزاشتم ولی زیر رادیو باتن زیر خط قرمز کشید
radioButton.Checked = false;
من چک کردم مشکلی نداشت
از کد زیر هم میتونید استفاده کنید :
foreach (Control control in tabPage1.Controls)
{
if (control is RadioButton)
{
RadioButton rb = control as RadioButton;
rb.Checked = false;
}
}
یا
foreach (RadioButton radioButton in tabPage1.Controls.OfType<RadioButton>())
radioButton.Checked = false;
برای استفاده از کد دوستمون کافیه متد رو فراخوانی کنید
public static void ClearRadio(Control root)
{
foreach (Control control in root.Controls)
{
//Clear(control);
if (control is RadioButton)
{
RadioButton rdbtn = (RadioButton)control;
rdbtn.Checked = false;
}
}
}
private void button1_Click(object sender, EventArgs e)
{
ClearRadio(tabPage1);
}
نکته
بجای tabPage1 نام آبجکت خودتون رو بنویسید