作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我只是在使用 Winforms 处理 .NET 提供的视觉样式,我遇到了一个问题。我只是执行这段代码,从自定义面板的 OnPaint 方法调用,没有什么特别的。
private void DrawBox(PaintEventArgs e)
{
ComboBoxRenderer.DrawDropDownButton(e.Graphics, e.ClipRectangle, ComboBoxState.Normal);}
我的问题是按钮的背景颜色是灰色,而真正的 ComboBox 的背景颜色是白色(无论如何在我的电脑上)。
这里有两个问题,为什么颜色会改变,以及如何使用与真正的 ComboBox 相同的背景颜色来渲染我的按钮?
谢谢丹尼
最佳答案
ClipRectangle 不是您想要的。设置您要绘制的实际矩形。话虽这么说,是的,使用 VisualStyles 会让你发疯。这将使您接近:
VisualStyleRenderer vsr = new VisualStyleRenderer("EDIT", 1, 1);
vsr.DrawBackground(e.Graphics, controlRectangle);
vsr.SetParameters("COMBOBOX", 7, 1);
vsr.DrawBackground(e.Graphics, arrowRectangle);
关于c# - VisualStyles 颜色不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52841897/
我只是在使用 Winforms 处理 .NET 提供的视觉样式,我遇到了一个问题。我只是执行这段代码,从自定义面板的 OnPaint 方法调用,没有什么特别的。 private void DrawBo
Microsoft 的 winforms 视觉样式一直让我感到困惑。 我试图让 Panel 位于 TreeView 旁边,并且只有相同的 VisualStyle 边框。 如您所见,TreeView 边
我有一个 ComboBox,我设置了 DrawMode = DrawMode.OwnerDrawFixed。然后我处理 OnDrawItem 事件,一切正常。但是,它看起来与标准 ComboBox 非
我是一名优秀的程序员,十分优秀!