¿Cómo puedo evitar que se compruebe un RadioButton cuando se carga el Formulario?
Parece que no puedo evitar que mi formulario verifique uno de losBotones de radi en miGroup Box
:
Como se muestra en el diseñador, noBotones de radi están marcadas allí.
Below es casi todo el código para este formulario simple. Nada requiere unBotones de radi para verificar aquí o en el diseñador del formulario.
Q: ¿Hay alguna manera de evitar cualquierBoton de radi de ser verificado cuando se carga el formulario?
public ValueTypeSelector() {
InitializeComponent();
radioButton1.Checked = false;
radioButton2.Checked = false;
radioButton3.Checked = false;
radioButton4.Checked = false;
radioButton5.Checked = false;
radioButton6.Checked = false;
button1.Enabled = false;
button1.Click += clickEvent;
button2.Click += clickEvent;
radioButton1.Click += clickEvent;
radioButton2.Click += clickEvent;
radioButton3.Click += clickEvent;
radioButton4.Click += clickEvent;
radioButton5.Click += clickEvent;
radioButton6.Click += clickEvent;
}
void OnShow(object sender, EventArgs e) {
foreach (RadioButton rad in Controls) {
if (rad.Checked) {
Console.WriteLine("WTF?");
}
}
}
void clickEvent(object sender, EventArgs e) {
RadioButton rad = sender as RadioButton;
if (rad != null) {
if (rad.Checked) {
if (rad == radioButton1) {
DataType = TableDataType.Boolean; // <= HERE IS THE PROBLEM! FIRES ON FORM LOAD
} else if (rad == radioButton2) {
DataType = TableDataType.Character;
} else if (rad == radioButton3) {
DataType = TableDataType.DateTime;
} else if (rad == radioButton4) {
DataType = TableDataType.Decimal;
} else if (rad == radioButton5) {
DataType = TableDataType.Integer;
} else if (rad == radioButton6) {
DataType = TableDataType.String;
} else {
return;
}
button1.Enabled = true;
}
} else if (sender == button1) {
DialogResult = DialogResult.OK;
Close();
} else if (sender == button2) {
DialogResult = DialogResult.Cancel;
Close();
}
}
ACTUALIZAR El problema es eseradioButton1
se verifica cuando se muestra el formulario:
if (rad == radioButton1) {
DataType = TableDataType.Boolean; // <= HERE IS THE PROBLEM! FIRES ON FORM LOAD
} else if (rad == radioButton2) {