DataGrid 中行的字体颜色
How can I change the font color of a row in DataGrid?
The color depends on a condition in the table.
I saw this post here on stackflow but it works only for the selected lines, and that the line would be another color, regardless of being selected or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需将事件处理程序添加到网格视图的
Paint
中即可。如果您想做的不仅仅是颜色,我们已经采取了从
DataGridViewCell
继承并重写其 Paint 方法的路线,从DataGridViewColumn
继承以使用该单元格,然后使用我们的网格视图中的该列。下面是重写的方法,但事件处理程序看起来类似。
You could just add an event handler to the grid view's
Paint
.If you want to do more than just the colour, we have gone the route of inheriting from
DataGridViewCell
and overriding its Paint method, inheriting fromDataGridViewColumn
to use that cell, then use that column in our grid view.Below is the overridden method, but the event hander would look similar.