datagrid小tip(一):鼠标的移动和点击变色
2007-02-06 14:49
477 查看
因为要经常使用datagrid,所以讲在网上搜到的一些美化和优化datagrid代码整理一下放到这里,备忘.
1.datagrid的行对鼠标的移动和点击变色的响应事件.
前台
<script language="javascript">
function aa(e)
{
for(var i=1;i<DataGrid1.rows.length; i++)
{
if(DataGrid1.rows[i].style.backgroundColor == "#f6ab00")
{
DataGrid1.rows[i].style.backgroundColor = "";
}
}
if(e.style.backgroundColor != "#f6ab00")
{
e.style.backgroundColor = "#f6ab00";
}
}
</script>
后台
private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType != ListItemType.Header)
{
e.Item.Attributes.Add("onmouseover","if(this.style.backgroundColor != '#f6ab00') this.style.backgroundColor='#f6f6f6'");
e.Item.Attributes.Add("onmouseout","if(this.style.backgroundColor != '#f6ab00') this.style.backgroundColor=''");
e.Item.Attributes.Add("onclick","aa(this)");
}
}
颜色可以根据页面风格进行修改
1.datagrid的行对鼠标的移动和点击变色的响应事件.
前台
<script language="javascript">
function aa(e)
{
for(var i=1;i<DataGrid1.rows.length; i++)
{
if(DataGrid1.rows[i].style.backgroundColor == "#f6ab00")
{
DataGrid1.rows[i].style.backgroundColor = "";
}
}
if(e.style.backgroundColor != "#f6ab00")
{
e.style.backgroundColor = "#f6ab00";
}
}
</script>
后台
private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType != ListItemType.Header)
{
e.Item.Attributes.Add("onmouseover","if(this.style.backgroundColor != '#f6ab00') this.style.backgroundColor='#f6f6f6'");
e.Item.Attributes.Add("onmouseout","if(this.style.backgroundColor != '#f6ab00') this.style.backgroundColor=''");
e.Item.Attributes.Add("onclick","aa(this)");
}
}
颜色可以根据页面风格进行修改
相关文章推荐
- 当鼠标移动到DataGrid上时让每行变色并且点击某行是弹出新页面
- DataGrid单元格移动变色,点击变色,双击取消颜色,排序.
- DataGrid单元格移动变色,点击变色,双击取消颜色,排序.
- 当鼠标点击或移动时,突出显示DATAGRID的行。。
- DATAGRID鼠标移动变色
- DataGrid:鼠标移动行变色、单击行弹出提示窗体
- DataGrid:鼠标移动行变色、单击行弹出提示窗体
- .net - 当鼠标移动到DATAGRID的某一行,整行变色?
- DataGrid和GridView鼠标移动上面背景变色
- DataGrid单元格移动变色,点击变色,双击取消颜色,排序.
- DataGrid中鼠标点击、移动后行颜色改变效果
- unity 鼠标拖动 物体旋转 点击变色 拖动移动
- DataGrid:鼠标移动行变色、单击行弹出提示窗体
- 鼠标移动时行变色并可以点击行时选中行
- JQuery实现表格隔行换色,鼠标移动变色,点击选择变色
- DataGrid单元格移动变色,点击变色,双击取消颜色,排序.
- DataGrid和GridView鼠标移动上面背景变色
- DataGrid单元格移动变色,点击变色,双击取消颜色,排序.
- 转:GridView鼠标移动行变色 (http://www.cnblogs.com/lovenets/articles/808071.html)[同ceng]
- C# Win32API 模拟鼠标移动及点击事件