我正在使用 devexpress winforms 网格。
我将数据集的数据绑定到 devexpress 网格。
dataGrid.MainView.GridControl.DataSource = ds;
dataGrid.MainView = gridView;
gridView.BestFitColumns();
网格显示会是这样的
FirstName LastName
Sharp Eye
我调用 RowStyle 事件来根据条件显示网格中行的背景颜色。
例如:
private void gridViewExcel_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
{
GridView View = sender as GridView;
string firstName = View.GetRowCellDisplayText(e.RowHandle, View.Columns["FirstName"]);
if (firstName="Sharp")
{
e.Appearance.BackColor = Color.Salmon;
e.Appearance.BackColor2 = Color.White;
}
else
{
//I want to append another column in the end to the dataset that is bound to the grid.
//With an error message...(see below)
}
}
输出
FirstName LastName Message
Sharp Eye First name doesn't match