鼠标移动 改变Datagrid行的背景颜色
2008-11-04 14:10
459 查看
protected void dgSjygl_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType==ListItemType.AlternatingItem))
{
//当鼠标移到的时候设置该行颜色
e.Item.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699CC'");
//当鼠标移走时还原该行的背景色
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
}
}
在DataGrid 里面的ItemDataBound事件
//颜色交替显示
if (e.Item.ItemIndex >= 0 && e.Item.DataItem is DataRowView)
{
DataRowView row = (DataRowView)e.Item.DataItem;
int numj = e.Item.Cells.Count;
for (int j = 0; j < numj; j++)
{
e.Item.Cells[j].ForeColor = System.Drawing.Color.Pink;
e.Item.Cells[j].BackColor = System.Drawing.Color.Blue;
}
}
{
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType==ListItemType.AlternatingItem))
{
//当鼠标移到的时候设置该行颜色
e.Item.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699CC'");
//当鼠标移走时还原该行的背景色
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
}
}
在DataGrid 里面的ItemDataBound事件
//颜色交替显示
if (e.Item.ItemIndex >= 0 && e.Item.DataItem is DataRowView)
{
DataRowView row = (DataRowView)e.Item.DataItem;
int numj = e.Item.Cells.Count;
for (int j = 0; j < numj; j++)
{
e.Item.Cells[j].ForeColor = System.Drawing.Color.Pink;
e.Item.Cells[j].BackColor = System.Drawing.Color.Blue;
}
}
相关文章推荐
- 鼠标移动,改变datagrid颜色
- 当鼠标移动时,改变datagrid中的颜色
- table鼠标移动背景,边框颜色改变
- 当鼠标移动到表格的一行时这一行的背景颜色发生改变
- 鼠标移动,改变datagrid颜色
- css如何做到 鼠标移动到超链接时,超链接会发生改变,例如改变颜色、字体大小、背景颜色等
- CSS:当鼠标移动到表格的某一行时改变其背景颜色
- js 当鼠标移动到表格一行上时,该行背景颜色改变
- DataGrid中鼠标点击、移动后行颜色改变效果
- WPF 设置DataGrid 鼠标移动改变行颜色样式
- asp.net GridView控件鼠标移动某行改变背景颜色(方法一)
- asp.net GridView控件鼠标移动某行改变背景颜色(方法一)
- MFC在鼠标自定义的一定的范围内实现拖动窗口移动、错误:不支持尝试执行的操作、实现进度条颜色的渐变或者背景和前景色的改变
- 鼠标移动,改变DataGrid颜色
- WPF 设置DataGrid 鼠标移动改变行颜色样式
- 鼠标移动,改变datagrid颜色 (转载)
- 鼠标移动,改变DataGrid颜色
- 设置WPF DataGrid 鼠标移动改变行颜色样式
- 鼠标悬停时改变Datalist背景颜色
- GDI:捕捉鼠标,实时改变矩形背景颜色。