I'm creating a custom toolbox in windows forms (like the one you pick the controls in the VS Form Designer). To get the image that appears on side of the text of the control I'm using this:
ToolboxItem tbi = item as ToolboxItem;
var image = tbi.Bitmap;
Where item can be any type of Control. It's working as it should be.
The problem happens when I try to use custom controls in the toolbox. Let's say I create this class:
public class PMLButton : Button
{
}
Then when the PMLButton is passed on the 'item' variable it get the gear icon, of a custom control, as it should. But in this case I would like to show the default button icon for this item.
All tools I'll use in the toolbox are derived from a default windows control class (Button, Label, Checkbox, etc).
If I cast the 'item' variable to its base type, it would work correctly and show the right image. Is there any way of doing this?
Aucun commentaire:
Enregistrer un commentaire