如下代码,我在关闭窗体是把RadioButton的当前索引值存到ini文件中
ridioButtonIndex = 0;
foreach (Control con in groupBoxClear.Controls)
{
if (con is RadioButton)
{
if ((con as RadioButton).Checked)
{
break;
}
ridioButtonIndex++;
}
}
Ini.IniWriteValue("清除文件", "day", ridioButtonIndex.ToString());
然后在窗体初始化时再读出来并解析索引
//读取保存天数索引
string deleteDay = Ini.IniReadValue("清除文件", "day");
switch (deleteDay)
{
case "4":
radioButtonNot.Select();
break;
case "3":
radioButtonDay3.Select();
break;
case "2":
radioButtonDay7.Select();
break;
case "1":
radioButtonDay15.Select();
break;
case "0":
radioButtonDay30.Select();
break;
default:
break;
}
窗体如下