DevExpress GridView 行颜色
DevExpress GridView Row Color
这里有人知道如何在 WinForms 上使用 DevExpress GridView 完成这种行吗?
您点击GridView,然后点击Theme,您可以从中选择。
我建议您阅读有关该主题的文档:Customizing Appearances of Individual Rows and Cells。
您可以通过多种方式做到这一点:
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.
示例:
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;
}
}
}
参考文献:
Changing Row Colours on DevExpress GridView
希望对您有所帮助..
下面是您在窗体的 DataGridView 控件中的操作方式。我想应该是相似的,自从我上次使用 DevExpress 以来已经有一段时间了。但是您应该仔细阅读 DevExpress 的文档,因为所有组件都有很好的文档记录。
foreach (DataGridViewRow row in dgInformation.Rows)
{
if (some criteria here == 1234)
{
row.DefaultCellStyle.BackColor = Color.Goldenrod;
}
}
这里有人知道如何在 WinForms 上使用 DevExpress GridView 完成这种行吗?
您点击GridView,然后点击Theme,您可以从中选择。
我建议您阅读有关该主题的文档:Customizing Appearances of Individual Rows and Cells。
您可以通过多种方式做到这一点:
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.
示例:
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;
}
}
}
参考文献:
Changing Row Colours on DevExpress GridView
希望对您有所帮助..
下面是您在窗体的 DataGridView 控件中的操作方式。我想应该是相似的,自从我上次使用 DevExpress 以来已经有一段时间了。但是您应该仔细阅读 DevExpress 的文档,因为所有组件都有很好的文档记录。
foreach (DataGridViewRow row in dgInformation.Rows)
{
if (some criteria here == 1234)
{
row.DefaultCellStyle.BackColor = Color.Goldenrod;
}
}