What the "x" button of a Window called? X Button?
I normaly call it the "close button", but I don't know if this is (or if there even is a) the official name.
Can I hide it (but not the whole top bar)? Can I hide only a few of the top buttons, like X and _ ?
AFAIK you can hide the minimize and maximize button or all of them, but not the close button alone. You can do that by setting the MaximizeBox
and/or MinimizeBox
property of the form to false
to hide the other two or ControlBox
to hide all of them.
But if the user closes the form2 using the "x" my app continues to run (because the mainForm still running, but hidden). I'd like to 'override the x button' to make it show form1, then hide/close the form2
You can register to the Closing
event. Inside the closing event you can then show form1
again:
private void Form2_Closing(object sender, CancelEventArgs e)
{
e.Cancel = true;
Hide();
var form1 = FindForm1(); // here you can insert your logic to get form1
form1 .Show();
}