Menu Hides Button

  • Thread starter Thread starter Martijn Mulder
  • Start date Start date
M

Martijn Mulder

When I place both a MenuStrip and a Button on my Form, the button covers
part of the menu. I hate to mess around with the Size and Location
properties of Controls, so normally I lay out my controls with instances
of FlowLayoutPanel and TableLayoutPanel. But in this case I cannot find
a reasonable solution.

What is a recommended way to avoid this problem?

using System.Windows.Forms;
class Examplet
{
static void Main()
{
Form form=new Form();
form.Text="Button Hides Menu";
form.Controls.Add(new Button());
form.Controls.Add(new MenuStrip());
Application.Run(form);
}
}
 
You need to allow space for everything. When using the designer,
simply drag the button.
One approach is often to use a Panel to represent the remaining client
array, and arrange items within this:

Form form = new Form();
form.Text = "Button Hides Menu";
// create a menu, and a panel for "the rest"
Panel clientArea = new Panel();
clientArea.Dock = DockStyle.Fill;
form.Controls.Add(clientArea);
form.Controls.Add(new MenuStrip());
// add the button to the panel
clientArea.Controls.Add(new Button());
Application.Run(form);

Marc
 
Marc Gravell schreef:
You need to allow space for everything. When using the designer,
simply drag the button.
One approach is often to use a Panel to represent the remaining client
array, and arrange items within this:

Thank you very much! Here is the revised Examplet:

using System.Windows.Forms;
class Examplet
{
static void Main()
{
Form form=new Form();
form.Text="Control Hides Menu";
Panel panel=new Panel();
panel.Dock=DockStyle.Fill;
panel.Controls.Add(new Button());
form.Controls.Add(panel);
form.Controls.Add(new MenuStrip());
Application.Run(form);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top