问题
Anyone here knows how to accomplish this kind of rows using DevExpress GridView on WinForms?
回答1:
I suggest you to go through documentation for the topic: Customizing Appearances of Individual Rows and Cells.
You can do this using various ways:
- Customizing Appearances
- Using the GridView.CustomDrawCell event
The GridView.RowStyle event can be handled to customize the appearance of individual rows in GridViews. To customize a specific cell's appearance, handle the GridView.RowCellStyle event instead. The GridView.RowStyle event fires before the GridView.RowCellStyle event.
Example:
using DevExpress.XtraGrid.Views.Grid;
private void gridView1_RowStyle(object sender,
DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e) {
GridView View = sender as GridView;
if(e.RowHandle >= 0) {
string category = View.GetRowCellDisplayText(e.RowHandle, View.Columns["Category"]);
if(category == "Beverages") {
e.Appearance.BackColor = Color.Salmon;
e.Appearance.BackColor2 = Color.SeaShell;
}
}
}
References:
Changing Row Colours on DevExpress GridView
Hope this help..
回答2:
You click on GridView and then click on Theme, you can choose from this.
回答3:
Here is how you would do in a DataGridView control in forms. Should be similar I assume, it has been a while since I last used DevExpress. But you should go through the DevExpress' documentation, since all of the components are very well documented.
foreach (DataGridViewRow row in dgInformation.Rows)
{
if (some criteria here == 1234)
{
row.DefaultCellStyle.BackColor = Color.Goldenrod;
}
}
来源:https://stackoverflow.com/questions/38045342/devexpress-gridview-row-color