How to solve the problem of merging the title bar of the child form and the menu bar of the main form by maximizing the child form of WinForm MDi, winformmdi
Write the following code in the ItemAdded event in the main form menu bar:
* MsMain is the Name attribute value in the menu bar of my main form.
// The private void msMain_ItemAdded (object sender, ToolStripItemEventArgs e) {if (e. item. text. length = 0) {e. item. visible = false;} else {e. item. visible = true ;}}
Note:
When the child form is maximized, the icon of the child form is no longer displayed on the left of the menu bar, and only the button on the right is retained.
If you only want to retain the close button, you only need to modify the code to the following:
// Remove the private void msMain_ItemAdded (object sender, ToolStripItemEventArgs e) when the sub-form is maximized {// if you do not need to close the button, you only need to add the code in parentheses after this if: | e. item. text = "close (& C)
If (e. item. text. length = 0 | e. item. text = "Restore (& R)" | e. item. text = "minimal (& N)") {e. item. visible = false;
}
Else
{
E. Item. Visible = true;
}}