locked
Form app RRS feed

  • Question

  • Hello so i have 2 forms one called form1 and the other one formoverlay so i have a check box and im trying to do when i check it it would open the other form but i cant it doesnt work    also i think its maybe the checkBoxShowOverlay because it says does snot exist anyway im only a beginer so i professianal should help 

    {
        public partial class Form1 : Form
        {
            Form_Overlay frm = new Form_Overlay();
            private object checkBoxShowOverlay;

            public Form1()
            {
                InitializeComponent();
            }

            private void textBox1_TextChanged(object sender, EventArgs e)
            {

            }

            private void checkBox4_CheckedChanged(object sender, EventArgs e)
            {
                if(checkBoxShowOverlay.Checked == true)
                {
                    frm.Show();

                }
                else
                {
                    frm.Hide();
                }

            }
        }
    }

        

    Tuesday, October 27, 2020 10:30 PM

Answers

  • Greetings RGwolf.

    checkBoxShowOverlay does not do anything. I think you need to look at the value of checkBox4.

            private void checkBox4_CheckedChanged(object sender, EventArgs e)
            {
                if(checkBox4.Checked == true) // checkBox4 here, not checkBoxShowOverlay.
                {
                    frm.Show();
    
                }
                else
                {
                    frm.Hide();
                }
    
            }

    This code probably will not do exactly what you want, but I hope it will get you started.

    Tuesday, October 27, 2020 10:48 PM

All replies

  • Greetings RGwolf.

    checkBoxShowOverlay does not do anything. I think you need to look at the value of checkBox4.

            private void checkBox4_CheckedChanged(object sender, EventArgs e)
            {
                if(checkBox4.Checked == true) // checkBox4 here, not checkBoxShowOverlay.
                {
                    frm.Show();
    
                }
                else
                {
                    frm.Hide();
                }
    
            }

    This code probably will not do exactly what you want, but I hope it will get you started.

    Tuesday, October 27, 2020 10:48 PM
  • I think you should move the constructor of your new form Form_Overlay frm = new Form_Overlay();

    to the checkbox event just before frm.Show() and rename checkBox4  to checkBoxShowOverlay.

     

    private void checkBoxShowOverlay_CheckedChanged(object sender, EventArgs e)
      {
                if(checkBoxShowOverlay.Checked == true)
                {
    
                    Form_Overlay frm = new Form_Overlay();
                    frm.Show();
                    this.Hide();
                }
    }

    Wednesday, October 28, 2020 4:13 AM
  • Thank you for the help it works now i have been trying to find it for hours 
    Wednesday, October 28, 2020 9:59 AM
  • Hi,

    Has your issue been resolved?

    If so, please click on the "Mark as answer" option of the reply that solved your question, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 29, 2020 2:46 AM