foreach (Control c in this.Controls) { if (c is Panel) { if (((Panel)c).Name == "pan_0") { int a = list[0].RockStyle; foreach (Control r in c.Controls) { if (r is RadioButton) { if (Convert.ToInt32(r.Tag) == a) { ((RadioButton)r).Checked = true; } } } }
如果是动态添加 那就要循环遍历
如果不是 那就一个个按ID取啊
foreach (Control c in this.Controls)
{
if (c is Panel)
{
if (((Panel)c).Name == "pan_0")
{
int a = list[0].RockStyle;
foreach (Control r in c.Controls)
{
if (r is RadioButton)
{
if (Convert.ToInt32(r.Tag) == a)
{
((RadioButton)r).Checked = true;
} }
}
}