1

I need to set a panel.Left property equal to a ToolStripButton.Left value:

pan1.Left = btn1.Left;  

but there is no such property for ToolStripButton. Is there a solution, please.

If there is no - how to place the panel on the center of a Form.

Buena
  • 2,461
  • 2
  • 20
  • 22

2 Answers2

1

You don't need any kind of control to infer center, but form itself:

panel1.Left = this.ClientSize.Width / 2 - panel1.Width / 2;
Agnius Vasiliauskas
  • 10,935
  • 5
  • 50
  • 70
  • Thank You, it works. But, I'm wondering that a button has not .Left value. – Buena Jun 18 '12 at 08:47
  • If you know index `N` of ToolStripButton then you can calculate it's `Left` by such formula `toolStrip1.Left + 10 /*some padding*/ + N * toolStrip1.Items[0].Width` – Agnius Vasiliauskas Jun 18 '12 at 09:28
1

this works:

pan1.Location = new Point(btn1.Bounds.X,pan1.Location.Y);  
Buena
  • 2,461
  • 2
  • 20
  • 22