how to use color in datagridview on change of color in highlight

Posted by Oswaldlily under VB.NET on 4/21/2014 | Points: 10 | Views : 748 | Status : [Member] | Replies : 2
In vb.net datagridview

mouseenter()
DgV.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.Cyan
DgV.Rows(e.RowIndex).DefaultCellStyle.ForeColor = Color.Black

mouse leave
DgV.Rows(e.RowIndex).DefaultCellStyle.ForeColor = Color.Black
DgV.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.white


in this both event,since change of colors,i couldn't type letters in cell,cause of "Color.white" in mouseleave event




Responses

Posted by: Saranpselvam on: 4/22/2014 [Member] Starter | Points: 25

Up
0
Down
HI try this one

if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#fed66c'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle;");
}

Please write this code on GridView1_RowDataBound event

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 4/22/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down

Login to post response