0

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:

No definition for '.IsChecked'

Sam O
  • 73
  • 1
  • 5
  • 1
    What are you targetting: Winforms, WPF, ASP..? YOU should __always__ TAG your questions correctly so one can see it on the questions page! – TaW Mar 13 '20 at 20:24
  • Hi, sorry I'm not familiar with this, as I'm quite new to Visual Studio. I had it tagged as C#. I would appreciate constructive help for future reference. – Sam O Mar 13 '20 at 21:43
  • Well, go ahead and add the Winfroms tag to your question! – TaW Mar 13 '20 at 23:21

1 Answers1

4

You can not change the value of IsChecked. Instead use the Checked property of the RadioButton.

Austin T French
  • 5,022
  • 1
  • 22
  • 40