不管是GridControl还是TreeList,自定义行/单元格的背景色、字体等可用CustomDrawNodeCell或NodeCellStyle(TreeList) 或 CustomDrawCell、RowStyle或RowCellStyle(GridControl)来实现
1、TreeList:
private void treeList1_CustomDrawNodeCell(object sender, CustomDrawNodeCellEventArgs e)
{
T row = treeList1.GetDataRecordByNode(e.Node) as T;
if (row == null) return;
if (row.StatId == 0)
{
e.Appearance.BackColor = Color.Red;
e.Appearance.ForeColor = Color.Gray;
e.Appearance.Font = new Font(e.Appearance.Font, e.Appearance.Font.Style | FontStyle.Italic);//斜体
}
}
2、GridControl:
private void gridView1_RowStyle(object sender, RowStyleEventArgs e)
{
GridView view = sender as GridView;
T row = view.GetRow(e.RowHandle) as T;
if (row == null) return;
if (string.IsNullOrEmpty(row.Name))
{
e.Appearance.BackColor = Color.Yellow;
}
}