我从未这样做,甚至不确定在哪里发布。对不起。
我在一个非常古老的网站上为这组三个单选按钮添加了另一部分。我相信我把它命名为rdoSheetfedPressMats0这是正确的代码吗?
它仍然允许我选择多个。我添加的是粗体。任何帮助将不胜感激。
private bool preventMoreThanOnePressMatSelection()
{
if (rdoSheetfedPressMats.SelectedIndex != -1 &&
rdoWebPressMats.SelectedIndex != -1 &&
rdoSheetfedPressMats0.SelectedIndex != -1)
{
rdoSheetfedPressMats.SelectedIndex = -1;
rdoWebPressMats.SelectedIndex = -1;
rdoSheetfedPressMats0.SelectedIndex = -1;
lblRawMatsSelect.Text = "You can only select one raw material type.";
lblAdditionalValSum.Text += "<br />- You can only select one raw material type.";
lblRawMatsSelect.ForeColor = Color.Red;
lblRawMatsSelect.Font.Italic = lblRawMatsSelect.Font.Bold = true;
return false;
}
else if (rdoSheetfedPressMats.SelectedIndex == -1 &&
rdoWebPressMats.SelectedIndex == -1 && chkUsedInPress.Checked)
{
lblRawMatsSelect.Text = "Select a raw material type.";
lblAdditionalValSum.Text += "<br />- Select a raw material type.";
lblRawMatsSelect.ForeColor = Color.Red;
lblRawMatsSelect.Font.Italic = lblRawMatsSelect.Font.Bold = true;
return false;
}
else
{
lblRawMatsSelect.Text = string.Empty;
return true;
}
}