Vlad from Moscow
Vlad from Moscow

Reputation: 310980

How to exclude the area occupied by MenuStrip from the client area of a form?

The area occupied by MainMenu is excluded from the client area of a form. However the area occupied by MenuStrip is included in the client area of a form As result if I will draw a string at coordinates 0, 0 then it will be overlapped by the MenuStrip.

How to make such a way that the area occupied by a MenuStrip would be excluded from the client area?

Upvotes: 1

Views: 793

Answers (2)

Vikas Gupta
Vikas Gupta

Reputation: 4465

AFAIK, You have only two options -

  1. Do the math yourself. (not my preferred solution).

  2. Use a simple panel as container for all your controls, except for the menu item itself. (my preferred solution, knowing what I know about winforms, only reasonable option which comes to mind).

Note that the second option is slightly different from other answer suggesting TableLayoutPanel.. IMHO, a simple panel would suffice.. as long as you take care of the Z-Order.

EDIT - Saw other comments on your question which were collapsed before.. After reading your comments, it is clear you have already excluded these options.. Sorry.

Upvotes: 1

BroVirus
BroVirus

Reputation: 164

That's pretty easy.

  • Create a TableLayoutPanel.
  • Set Dock: Fill.
  • Delete the last column. Now you have only 1 column.
  • Set row1 to 23-25px and row2 to autosize.

  • Now Drag and drop your menu into the first cell/row and your "client-area" (Panel?) to the second one.

If you have some troubles to drag and drop them just use the document outline.

Edit: Have you tried a simple menustrip1.SendToBack(); to change the z-order? Or a Control.BringToFront(); for your string/etc.?

Upvotes: 2

Related Questions