我的mdiMain StyleManager属性在ManagerStyle :Office2013MetrocolParameters:CanvasColor:黑色,基色:白色和我的子窗体下面,我想给Combo提供不同的背景色和边框颜色,就像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;
}
发布于 2014-11-18 17:50:34
下面是解决我的问题的代码,我使用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;
https://stackoverflow.com/questions/26998311
复制相似问题