首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

winform DataGridView根据光标位置设置所在行的背景颜色解决思路

2012-02-01 
winform DataGridView根据光标位置设置所在行的背景颜色如题。。。[解决办法]C# codeprivate void gv_CellMou

winform DataGridView根据光标位置设置所在行的背景颜色
如题。。。

[解决办法]

C# code
private void gv_CellMouseEnter(object sender, DataGridViewCellEventArgs e)        {            if (e.RowIndex != -1)            {                object prevIndex = gv.Tag;                if (prevIndex == null || !prevIndex.Equals(e.RowIndex))                {                    gv.Tag = e.RowIndex;                    gv.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red;                    gv.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Blue;                }            }        }        private void gv_CellMouseLeave(object sender, DataGridViewCellEventArgs e)        {            if (e.RowIndex != -1)            {                gv.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.White;                gv.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.FromArgb(0, 64, 64);            }        } 

热点排行