简体   繁体   中英

Panel in StatusStrip?

Is it possible to have a panel in a StatusStrip ? MSDN is kind of saying so:

The default StatusStrip has no panels. To add panels to a StatusStrip, use the ToolStripItemCollection.AddRange method [...]

... but I can't find how.

I tried to add a Panel or a ToolStripPanel to a StatusStrip , but it is only accepting ToolStripItem s. On the other hand, I tried adding a ToolStripItem to a Panel or a ToolStripPanel , but both only accepts Control s:

ToolStripPanel toolStripPanel = new ToolStripPanel();
toolStripPanel.Controls.Add(toolStripStatusLabel);   // Wrong
statusStrip.Items.AddRange(toolStripPanel);          // Wrong again

What's interesting is that in Microsoft terms

ToolStripStatusLabel - Represents a panel in a StatusStrip control.

So their panel is really a Label. Unless that's a mistake in their documentation, what you are trying to do is impossible, as there is no Panel class that can be hosted inside StatusStrip.

You can use the ToolStripStatusLabel. In order to have the look and feel of a Panel, simply set the following properties of the ToolStripStatusLabel: BorderSides = All, BorderStyle = SunkenOuter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM