Cancel button

jag250

Active member
Joined
Sep 16, 2020
Messages
28
Programming Experience
1-3
what code can I use behind a cancel button to close a panel?

Below is the code I tried.
pnlAddCourses.Visible = true;
I have also tried
this.Close();
 
Explain what you are trying to do?

A panel is a container for other controls. You don't just close them.

Disabling them will disable the controls inside them. Setting visibility will change the visibility of the controls inside them too. Neither of these sound like what you want...

When you say you want to close a panel, define close?

If you want to close it, why not use Mdi?

  • Perhaps explaining what you are doing
  • How you are doing it (Provide your code)
  • Explain what you expect to happen
  • And report what is happening, and maybe you will get better responses.
 
Explain what you are trying to do?

A panel is a container for other controls. You don't just close them.

Disabling them will disable the controls inside them. Setting visibility will change the visibility of the controls inside them too. Neither of these sound like what you want...

When you say you want to close a panel, define close?

If you want to close it, why not use Mdi?

  • Perhaps explaining what you are doing
  • How you are doing it (Provide your code)
  • Explain what you expect to happen
  • And report what is happening, and maybe you will get better responses.
the button is canceled so it should cancel the option of what I'm doing so trying to get the panel to disappear because I would no longer need it
 
I'll just point out that your one liner replies are not specific enough to help you.

That said; if you want to do it in a fancy way, you could use a timer to fade the opacity of the panel you are using. Search around for snippets and I'm sure you will find many. I don't feel like writing one out...

Simply removing a control, will leave an empty space in your UI where it resided. Sounds like a bad design, but then again, I don't know what you're doing because you never explained it.

If you don't want the control, then you can remove it Form1.ActiveForm.Controls.Remove(ControlNameHere); - Note: adding it back to your form will require you know it's previous properties.

Sounds like a horrible UI, but then again, I don't know if you plan on replacing the panel with something in its place. Read this : Control.ControlCollection.Remove(Control) Method (System.Windows.Forms)
 
Is this a WebForms question again?
 
Is this a WebForms question again?
Again? :rolleyes:

I'm guessing this is the moderating team right about now.....

giphy.gif


That's it, you keep posting specific questions in a non specific board, and expect to get the right advice.

Next time you post, I will be sure to take out my crystal ball.
 

Latest posts

Back
Top Bottom