隔行显示就是建个按钮:
然后设置按钮的属性:
private void button_Click(object sender, System.EventArgs e)
{
dataGrid1.AlternatingBackColor=Color.Red;

}
你点击按钮,表就会出现红白相间的颜色,如果你想指定某一行的话,不好意思,偶还在学习中~~

解决方案 »

  1.   

    如何屏蔽掉,用delete键删除掉datagrid中的一行记录,这种功能呢?
      

  2.   

    如果你用的是webform中的DataGrid,需要加入脚本语言才能实现选定行在鼠标移动时颜色发生改变,另外需要在
    DataGrid中需要加入ItemDataBound事件,代码如下:
    private void DG_UpDetail_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {//鼠标移动到指定行的高亮显示
    e.Item.Cells[1].Style.Add("cursor","hand");//指定哪一列实现指针变手形
            e.Item.Cells[2].Style.Add("cursor","hand");
               
    if(e.Item.ItemType == ListItemType.Item )
                 {
                   e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='blue'");//指定鼠标移到记录上时的颜色
                   e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='Silver'");//指定鼠标移出记录时的颜色
                 }
    else if(e.Item.ItemType == ListItemType.AlternatingItem)
    {
      e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='blue'");
      e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='SteelBlue'");
    } }