How to change the color of a check mark or 'more' arrow on a WinForms context menu?

醉酒当歌 提交于 2019-12-11 03:14:37

问题


I have a context menu that needs to use a dark background. It uses a check margin and has several sub-menus. The check mark and the arrow indicating a sub-menu are both black and thus hard to see. I can find no way to change the color. (It would seem obvious to me that they ought to use the ForeColor, which we have set to white for the text, but this does not seem to affect the check marks or arrows.)

Is there a way to do this?

EDIT: We are using images in the image margin as a work-around. But we have other problems with that and before trying to solve them, I thought I'd try to get a simpler solution to the basic problem.


回答1:


What I did in the past in similar cases was to "emulate" the checkbox by switching context menu images.

I.e. I remember whether the menu item is checked/unchecked (i.e. as a boolean inside the Tag of the menu item) and then change the picture appropriately to either a check image or no image, depending on the menu item's state.

Probably you could even derive your own class from MenuItem and change the check therein transparently to the user of the derived class.

For the arrow on the right, I assume you could emulate it by drawing an arrow with another font (Wingdings e.g.?) inside the area where the shortcuts are being displayed.

Or, as a completely different approach, use the owner draw functionality of the MenuItem.



来源:https://stackoverflow.com/questions/7907940/how-to-change-the-color-of-a-check-mark-or-more-arrow-on-a-winforms-context-me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!