隔行显示就是建个按钮:
然后设置按钮的属性:
private void button_Click(object sender, System.EventArgs e)
{
dataGrid1.AlternatingBackColor=Color.Red;
}
你点击按钮,表就会出现红白相间的颜色,如果你想指定某一行的话,不好意思,偶还在学习中~~
然后设置按钮的属性:
private void button_Click(object sender, System.EventArgs e)
{
dataGrid1.AlternatingBackColor=Color.Red;
}
你点击按钮,表就会出现红白相间的颜色,如果你想指定某一行的话,不好意思,偶还在学习中~~
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'");
} }