datagrid 上面的行的光亮条跟随鼠标移动
可以实现光亮条的选择
设置指定行的颜色
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
{
if (e.Item.ItemIndex == (i_currentline-1))
{
e.Item.BackColor = System.Drawing.Color.Yellow;
}
}行颜色交替显示:



在DataGrid 里面的ItemDataBound事件

//颜色交替显示
if (e.Item.ItemIndex >= 0 && e.Item.DataItem is DataRowView)
{
DataRowView row = (DataRowView)e.Item.DataItem;
int numj = e.Item.Cells.Count;
for (int j = 0; j < numj; j++)
{
e.Item.Cells[j].ForeColor = System.Drawing.Color.Black;
e.Item.Cells[j].BackColor = System.Drawing.Color.SkyBlue;
}
}

浙公网安备 33010602011771号