如何处理 ContextMenuStrip 属性,特别是边框颜色

How to handle ContextMenuStrip property, exspecially border color

如何处理ContextMenuStrip属性,尤其是border-color???

C# 中的任何方法或使用 Windows API (DllImport) 的任何方式?

您可以创建自定义颜色 table 并更改渲染器 属性:

 public class MenuColorTable : ProfessionalColorTable
{
    public MenuColorTable()
    {
        UseSystemColors = false;
    }
    public override Color MenuBorder
    {
        get { return Color.Fuchsia; }
    }
    public override Color MenuItemBorder
    {
        get { return Color.DarkViolet; }
    }
    public override Color MenuItemSelected
    {
        get { return Color.Cornsilk; }
    }
    public override Color MenuItemSelectedGradientBegin
    {
        get { return Color.LawnGreen; }
    }
    public override Color MenuItemSelectedGradientEnd
    {
        get { return Color.MediumSeaGreen; }
    }
    public override Color MenuStripGradientBegin
    {
        get { return Color.AliceBlue; }
    }
    public override Color MenuStripGradientEnd
    {
        get { return Color.DodgerBlue; }
    }
}

改变Renderer

contextMenuStrip1.Renderer = new ToolStripProfessionalRenderer(new MenuColorTable());

结果如下: