开发者

Display an image in one MenuItem without resizing the other MenuItems in a ContextMenuStrip

开发者 https://www.devze.com 2023-01-02 11:12 出处:网络
I have a ContextMenuStrip with two MenuItems on it. I would like to display an image on one of those items but when I do this, the other item resizes to the image scaling size of the MenuStrip, even t

I have a ContextMenuStrip with two MenuItems on it. I would like to display an image on one of those items but when I do this, the other item resizes to the image scaling size of the MenuStrip, even though it does not have an image itself. Is there a way around this to just resize the item that has an image without affecting the others?

Update: First I've tried setting ImageScaling property of the MenuItem 开发者_如何学PythonI didn't want resized to None. This had no effect and neither did playing around with the AutoSize or SizeMode properties.

I've had some success by using the BackgroundImage property instead of the Image property of the MenuItem and just manually setting the size of the MenuItem to be displayed. But I can't get the text to appear at the bottom of the MenuItem, even though I've set the TextAlign property to BottomCenter. Plus, using the BackgroundImage property seems like a work-around rather than a good solution.


Set ImageScaling to SizeToFit (the default) for the ToolStripMenuItem that has the image.

0

精彩评论

暂无评论...
验证码 换一张
取 消