我有一个Devexpress Xtragrid,我在其中根据特定列对行进行分组。我给组了深蓝色,并将ShowGroupExpandCollpaseButton设置为false。在每个子网格的最左边部分,网格中的行显示我设置为组背面颜色的颜色。有没有办法去除这种颜色?
答案 0 :(得分:1)
要完成此任务,请从GroupRow外观中删除BackColor
。
然后使用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;
}
答案 1 :(得分:0)
您应该可以通过如下设置隐藏视图中的组:
this.gridView1.OptionsView.ShowGroupedColumns = false;