DataGrid鼠标到达的行和列显示不同的颜色
2006-02-19 13:58
344 查看
本例的实现原理是在向DataGrid绑定数据的同时为相应的单元格添加onmouseover和onmouseout事件。主要代码如下
1
/**//// <summary>
2
/// 增加颜色属性
3
/// </summary>
4
/// <param name="sender"></param>
5
/// <param name="e"></param>
6
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
7
{
8
if(e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
9
{
10
e.Item.Attributes.Add("onmouseover","this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#C8F7FF'");
11
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor");
12
for (int i=0;i<DataGrid1.Columns.Count;i++)
13
{
14
e.Item.Cells[i].Attributes.Add("onmouseover","this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#99ccff'");
15
e.Item.Cells[i].Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor");
16
}
17
}
18
}
1
/**//// <summary>
2
/// 增加颜色属性
3
/// </summary>
4
/// <param name="sender"></param>
5
/// <param name="e"></param>
6
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
7
{
8
if(e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
9
{
10
e.Item.Attributes.Add("onmouseover","this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#C8F7FF'");
11
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor");
12
for (int i=0;i<DataGrid1.Columns.Count;i++)
13
{
14
e.Item.Cells[i].Attributes.Add("onmouseover","this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#99ccff'");
15
e.Item.Cells[i].Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor");
16
}
17
}
18
}
相关文章推荐
- DataGrid鼠标到达的行和列显示不同的颜色
- DataGrid鼠标到达的行和列显示不同的颜色
- 在DataGrid中,使鼠标到达的行和列显示不同的颜色 (转载)
- DataGrid鼠标到达的行和列显示不同的颜色
- 在DataGrid中,使鼠标到达的行和列显示不同的颜色
- 在DataGrid中,使鼠标到达的行和列显示不同的颜色
- 在DataGrid中,使鼠标到达的行和列显示不同的颜色
- DataGrid鼠标指向时显示不同颜色
- DataGrid中加多选按钮 和 鼠标移动显示不同的颜色
- DataGrid鼠标指向时显示不同颜色
- 自己对“用不同颜色显示表格奇偶行的例子”扩充了用不同颜色显示鼠标单击的行 - 张孝祥专栏 - CSDNBlog
- 自己对“用不同颜色显示表格奇偶行的例子”扩充了用不同颜色显示鼠标单击的行
- silverlight中颜色转换,实现DataGrid 行不同颜色显示
- winform中dataGridView隔行显示不同的背景色,鼠标移动上显示不同颜色,离开后变回原色
- 自己对“用不同颜色显示表格奇偶行的例子”扩充了用不同颜色显示鼠标单击的行
- 鼠标覆盖行高亮显示 奇偶行背景颜色不同 css+jquery Table
- js 函数 隔行鼠标划过显示不同颜色
- 自己对“用不同颜色显示表格奇偶行的例子”扩充了用不同颜色显示鼠标单击的行
- 消除方块+不同颜色score加减分+player是否出界+鼠标控制+窗口显示得分
- FLEX4实践—DatagridColumn根据条件显示不同颜色