数据网格视图标题网格颜色
这是一个 VB .NET 应用程序,我们在数据网格视图中显示 SQL 语句的输出。我使用的是.NET 2005。
我们需要使网格控件上的标题分隔符的颜色与表单上的GridColor 的颜色相同。
我们尝试查看 DataGridView 控件的所有属性,并发现了一些看起来很有希望的有趣的东西,例如 DataGridViewAdvancedHeaderStyle 和 DataGridViewHeaderBorderStyle,但它们似乎都不允许您更改其上的颜色。
有谁知道如何在不使用 GDI+ 控件重新制作整个东西的情况下做到这一点?
This is a VB .NET application where we are showing the output of a SQL statement in a Datagrid view. I'm using .NET 2005.
We need to get the separators of the headers on the grid control to be the same colors as the GridColor on the form.
We've tried looking through all of the properties of the DataGridView control, and found some interesting things that looked promising such as the DataGridViewAdvancedHeaderStyle, and DataGridViewHeaderBorderStyle, but none of it seems to allow you to change the colors on it.
Does anyone know how to do this without remaking the entire thing with a GDI+ control?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,我从来没有找到这个属性,所以我最终创建了一个自定义组件,并重载 OnPaint 事件处理程序以在现有组件上画一条线。
如果其他人遇到这篇文章寻找解决方案,这里是它的代码:
Well, I never did find a property for this, so I ended up creating a custom component, and overloading the OnPaint event handler to draw a line over the existing one.
Here is the code for it if anyone else ever comes across this post looking for a solution:
要更改 datagridview 中列标题的背景色,请为 EnableHeadersVisualStyles 选择 False。然后打开 ColumnHeadersDefaultCellStyle 并选择背景颜色。
To change the backcolor of the Column Headers in a datagridview, choose False for EnableHeadersVisualStyles. Then open ColumnHeadersDefaultCellStyle and choose the background color.
我看不到图片,但是玩一下怎么样?
I can't see the picture but what about playing with these?