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