【救命了】求助【救命了】在datagridivew 怎样实现只有选中行变色 其他行不变色 如题 求助啊 救命乐 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 protected void gvBooks_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor"); } } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { int i; for (i = 0; i <= GridView1.Rows.Count; i++) { //首先判断是否是数据行 if (e.Row.RowType == DataControlRowType.DataRow) { //当鼠标停留时更改背景色 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'"); //当鼠标移开时还原背景色 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c"); //单击行的任意列会自动选中此行 e.Row.Attributes.Add("onclick", "__doPostBack('GridView1','Select$" + e.Row.RowIndex + "')"); } } datagridivew 是winform 控件本身选中了就是 蓝色背景的 RowDataBound 没找到这个事件啊 T T 崩溃了 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onMouseOver", "t=this.style.backgroundColor;this.style.backgroundColor='#ebebce'"); e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=t"); e.Row.Attributes.Add("onclick", "if(this.style.backgroundColor=='#ebebce')this.style.backgroundColor=t;else{this.style.backgroundColor='#ebebce'}"); e.Row.Attributes.CssStyle.Add("cursor", "hand"); } } datagridivew 选中行背景颜色本来就是蓝色的 貌似datatgridview最后行是没有数据的,就不用去判断最后行的吧 关于Sidebar的使用,看我的思路有没有错 js 获取treeview节点的Text和value值 急,连接DB问题,高分求 为什么截屏发送图片的时候出现错误?大家帮忙看一下。。。。 backgroundWorker中OpenFileDialog()出错 怎么在winform datagrid的最前面添加一checkbox列? 基于picturebox的自定义控件如何当图像过大时,显示滚动条? 字符串转换成运算 大家来讨论一下C#的书籍吧。 VS2017 按空格键没智能提示?????请教设置方法! 有关XML问题 求助,为何不能操作数据库中数据????
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
int i;
for (i = 0; i <= GridView1.Rows.Count; i++)
{
//首先判断是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
//单击行的任意列会自动选中此行
e.Row.Attributes.Add("onclick", "__doPostBack('GridView1','Select$" + e.Row.RowIndex + "')");
}
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onMouseOver", "t=this.style.backgroundColor;this.style.backgroundColor='#ebebce'");
e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=t");
e.Row.Attributes.Add("onclick", "if(this.style.backgroundColor=='#ebebce')this.style.backgroundColor=t;else{this.style.backgroundColor='#ebebce'}");
e.Row.Attributes.CssStyle.Add("cursor", "hand");
} }