0

我的 mdiMain StyleManager 属性低于 ManagerStyle :Office2013 MetroColorParameters:CanvasColor:black, baseColor:White 和我的子窗体我想为 Combo Box 提供不同的背景颜色和边框颜色,因为 StyleManager 它是黑色,我希望它更改为白色背景灰色边框。

在我的 StyleManager 更改样式后,我正在使用以下代码更改颜色

         LinearGradientColorTable linGrBrush = new LinearGradientColorTable(
         Color.FromArgb(192, 192, 192),  
         Color.FromArgb(104, 104, 104));  

            if (GlobalManager.Renderer is Office2007Renderer)
            {
              Office2007ColorTable ct = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;

              ct.ComboBox.DroppedDown.Background = Color.White;
              ct.ComboBox.Default.Background = Color.White;
              ct.ComboBox.Default.ExpandBackground = linGrBrush;
              ct.ComboBox.DroppedDown.Border = Color.Gray;
              ct.ComboBox.Default.Border = Color.Gray; 
             }
4

1 回答 1

0

下面是解决我的问题的代码我使用 ComboBox.DefaultStandalone 属性而不是 ComboBox.Default

       LinearGradientColorTable linGrBrush = new LinearGradientColorTable(
           Color.DarkGray,
           Color.DarkGray);

        Office2007Renderer renderer = GlobalManager.Renderer as Office2007Renderer;
        if (renderer == null) return;
        Office2007ColorTable table = renderer.ColorTable;
        // Stand-alone ComboBoxEx colors
        Office2007ComboBoxColorTable comboColors = table.ComboBox;
        comboColors.DefaultStandalone.Border = Color.DarkGray;
        comboColors.DefaultStandalone.Background = Color.White;
        comboColors.DefaultStandalone.ExpandText = Color.LightGray;
        comboColors.DefaultStandalone.ExpandBorderInner = linGrBrush;
        comboColors.DefaultStandalone.ExpandBorderOuter = linGrBrush;
于 2014-11-18T17:50:34.767 回答