I am working on a C# desktop application. I am using a menu strips control
in which I have used a drop down button
.
Whenever the dropdown is clicked, it displays items, but the Width of the Dropdown Menu seems to be the issue, it's always greater. I want it to be the same size at that of the button.
Here is a screenshot:
What I am struggling to configure:
Unfortunately you are going against the grain for this control, and you will need to resort to your own controls or custom painting to get exactly what you want.
You should be able to change the shape/size of the drop down arrow using custom painting. You should be able to restrict the size of the drop down menu by overriding the control. However as the drop down menu has space for ticks and shortcut strings I suspect you may need to do more work than you were expecting.
Here are a couple of pointers that you may find helpful: http://connect.microsoft.com/VisualStudio/feedback/details/97456/owner-drawn-toolstripcombobox
This suggests using the ToolStripControlHost(control) to host arbitrary controls. With a simple example at: http://alala666888.wordpress.com/2010/07/15/custom-toolstripitem/
http://www.codeproject.com/KB/static/DropDownContainer.aspx This project (albeit in VB.Net) shows many of the issues with writing your own controls to do the same thing.
There is also this article about writing ToolStripRenderers: http://www.codeproject.com/KB/menus/CustomToolStripRenderer.aspx
Here's another C# based example of a custom control: http://www.codeproject.com/KB/selection/office2003colorpicker.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With