我使用的DevExpress WinForms的網格。如何動態地添加列在網格的DevExpress數據網格
我從數據集到的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
爲什麼不能多一個列添加到您的數據表?或者將'UnBoundGridColumn'添加到網格 –