I am writing a program to run a testing tool that has two cameras, named Pias and DinoLite. The operator can select which camera is to be active by two radio buttons. I am trying to implement an exception where if an operator tries to select a camera which is not connected, the program will ask if they want to restart with the correct camera installed. If the operator says no, I would like the radio buttons to revert to the previous camera. However, for some reason, the .IsChecked method for radio buttons is not available. Is there a property I must change first? I've seen other posts about using .IsChecked and I couldn't find a similar issue.
Here is my code for the radio button (forgive me if it's appalling, I'm a mechanical engineer by training):
private void pias_mode_CheckedChanged(object sender, EventArgs e)
{
MessageBox.Show("Please ensure the correct camera is installed. Press OK when finished.", "Camera Switch", MessageBoxButtons.OK);
if (pias_mode.Checked)
Mode_Indicator.Text = "Pias Mode";
}
private void dino_mode_CheckedChanged_1(object sender, EventArgs e)
{
if (dino_mode.Checked)
Mode_Indicator.Text = "DINO Mode";
measuringZ = 100;
try //detects if DinoLite camera is connected
{
axDNVideoX1.Connected = true;
axDNVideoX1.Preview = true;
}
catch (Exception)
{
DialogResult dialogresult = MessageBox.Show("Could not find DinoLite camera. Would you like to connect DinoLite camera? This will require the program to exit.", "Device not Found", MessageBoxButtons.YesNo);
if (dialogresult == DialogResult.Yes)
{
Close();
}
else if (dialogresult == DialogResult.No)
{
pias_mode.IsChecked = true;
}
}
}
Visual studio tells me there is no definition for '.IsChecked'
Here is what it looks like:
You can not change the value of IsChecked. Instead use the Checked
property of the RadioButton.