我有一个 Devexpress Xtragrid,我在其中根据特定列对行进行分组。我为 Group 赋予了深蓝色背景色,并将 ShowGroupExpandColpaseButton 也设置为 false。在网格中每个子行的最左侧显示我设置为组背景颜色的颜色。有什么办法可以去除这种颜色吗?
问问题
1683 次
2 回答
1
要完成此任务,请BackColor
从GroupRow外观中删除 。然后根据需要使用CustomDrawGroupRow事件突出显示组行内容:
// 1) remove GroupRow style
//gridView1.Appearance.GroupRow.BackColor = Color.Blue;
gridView1.OptionsView.ShowGroupExpandCollapseButtons = false;
// 2) use the CusomDrawGroupRow
gridView1.CustomDrawGroupRow += gridView1_CustomDrawGroupRow;
}
void gridView1_CustomDrawGroupRow(object sender, RowObjectCustomDrawEventArgs e) {
GridView gridView = sender as GridView;
GridGroupRowInfo groupRowInfo = e.Info as GridGroupRowInfo;
string groupRowText = gridView.GetGroupRowDisplayText(e.RowHandle);
int textStart = groupRowInfo.DataBounds.Left + 4;
Rectangle groupRowTextBounds = new Rectangle(
textStart,
groupRowInfo.Bounds.Top,
groupRowInfo.Bounds.Right - textStart,
groupRowInfo.Bounds.Height
);
e.Cache.FillRectangle(Brushes.Blue, e.Bounds); // draw blue backgrownd
e.Appearance.DrawString(e.Cache, groupRowText, groupRowTextBounds);
e.Handled = true;
}
于 2013-04-28T10:59:27.013 回答
0
您应该能够通过如下设置从视图中隐藏组:
this.gridView1.OptionsView.ShowGroupedColumns = false;
于 2013-04-28T12:21:47.533 回答