请问,我在用C#做ASP.NET web应用程序时,我现在绑定了一个DataGril网格控件,打开此web网页的时候,把我数据库中指定的表内容打开并显示出来啦,我现在想实现的功能是:当我鼠标移动到记录上时,此记录呈现高亮显示并且当鼠标移走时记录形状又恢复为原状!!     请问,该如何实现??谢谢!!!     还有,就是当我打开一个网页的时候,鼠标的形状也发生了变化,不在是默认的尖头形状,请问,应该如何实现??!

解决方案 »

  1.   

    设置DataGrid的ItemDataBound事件,添加如下代码:
    if(e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item )
    {
    e.Item.Attributes.Add("onmouseover", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#C8F7FF'");
    e.Item.Attributes.Add("onmousedown", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#C8F7FF'");
    e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor");
    for (int i = 0; i< grdJieGuo.Columns.Count; i++ )
    {
    e.Item.Cells[i].Attributes.Add("onmouseover", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#99ccff'");
    //e.Item.Cells[i].Attributes.Add("onmousedown", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#99ccff'");
    e.Item.Cells[i].Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor");
    }
    }
      

  2.   

    在DataGrid的ItemDataBound事件中加:if(e.Item.ItemType == ListItemType.Item  || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    //添加自定义属性,当鼠标移过来时设置该行的背景色为"6699ff",并保存原背景色
    e.Item.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
    //添加自定义属性,当鼠标移走时还原该行的背景色
    e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor"); }
      

  3.   

    如果是cs程序,可以这样控制鼠标:
    System.ComponentModel.Component如果是B/S程序,好像不可以控制吧?一起学习 :)
      

  4.   

    不好意思刚写错了,应该是这样:
    this.Cursor = Cursors.WaitCursor;:)
      

  5.   

    在datagrid的itemdatabound事件里面添加
    if(e.item.itemindex>=0)
    {
      e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#C8F7FF'");
     e.Item.Attributes.Add("onmousemove", "this.style.backgroundColor=原颜色");
    }
    至于打开网页变鼠标
    <BODY style='cursor:url(http://www.webjx.com/js/mouse/mouse.cur)'>
    在body部分的style添加上述代码
    http://www.kupage.com/webdesign/5/20031111/1005050000030vy7jhdx.htm或者你看下这个
      

  6.   

    在aspx文件的body部分你打出style=后会出现提示的然后单击操作可以出现一个设置style的对话框里面酒友设置鼠标的部分