I am making a system using C# and I am just new to using the User Control with the forms. So what I wanted to do is to hide the current form that holds the user control using the button placed in the user control. Is there any way to do this? I need the code for the button in user control.
Additional Details:
I have the Form1 in which a user control is docked to it, the user control is named as UserControl1 and it has a button, I want that button to open another form which is Form2 and in the process is to hide the Form1 that holds the UserControl1.
CodePudding user response:
Inside your UserControl:
this.ParentForm.Close();
About Close: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.form.close?view=windowsdesktop-6.0