如何在选定的DataGridView行上更改颜色 [英] How to change color on selected datagridview row

查看:119
本文介绍了如何在选定的DataGridView行上更改颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想做的是,当我在数据网格中选择不同的行时,所选内容将采用不同的颜色..

例如,我有4行,现在当我选择第一行时,我希望它为绿色,当我选择第二行时,我希望它为红色(以此类推,以此类推)

Hi,

What i wanna do is when i select different row in the datagrid the selection to be in different color..

For example, i have 4 rows, now when i select the first row i want it to be green, when i select on 2nd i want it to be red (etc etc, just as an example)

so how could i do this?

推荐答案

当然可以.

只需跟踪datagridview的CellEnter事件并检查是否选择了该行即可.如果选择了行,则使用以下文章来更改行颜色.

http://msdn.microsoft.com/en-us/library/1yef90x0.aspx

希望有帮助!
Definitely you can do this.

Just track CellEnter event of datagridview and check if the row is selected or not. If row is selected then change rows color by using following article.

http://msdn.microsoft.com/en-us/library/1yef90x0.aspx

Hope this help!


这篇关于如何在选定的DataGridView行上更改颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆