F
F
foxlye2019-04-19 17:08:27
C++ / C#
foxlye, 2019-04-19 17:08:27

How to hide form, Hide and Opacity not working?

How to hide form, Hide and Opacity not working?
The code itself:

Form1 Otris = new Form1(Cursor.Position.ToString());
            if (checkBox1.Checked == true)
            {
                checkBox1.ForeColor = Color.FromArgb(188, 87, 206);
                Otris.Show();
            }
            else
            {
                checkBox1.ForeColor = Color.FromArgb(87, 184, 206);
                Otris.Hide();
                Otris.Opacity = 0;
            }

For some reason, when you uncheck the box, the form does not disappear.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman, 2019-04-19
@foxlye

If all this code is written in the checkbox state change handling, then the problem is obvious: you always have a new form created.
The link to the open and displayed form must be kept outside the method and hidden.

B
BasiC2k, 2019-04-19
@BasiC2k

Try not to change transparency but set .Visible = False

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question