You cannot overlay ToolStripDropDownButton on ToolStripButton since the former does not inherit from the latter. However, both inherit from ToolStripItem , so you can use them instead.
Your opinion:
var button = ((btnSoles as ToolStripItem) as ToolStripButton);
However, this will not do what you want. Firstly, btnSoles always a ToolStripItem , so instead of using it directly, you should use:
var item = (ToolStripItem)btnSoles;
Then, if you really need the functionality provided by ToolStripButton and not ToolStripItem , then you should use as :
var button = btnSoles as ToolStripButton;
This will return null if btnSoles cannot be added to the ToolStripButton . If it is ToolStripDropDownButton , as you say, then it cannot be distinguished, and the result will be null . Please note that a double throw is not needed and is rarely required at all.
source share