【问题标题】:Row Group Issue in Row Background Color行背景颜色中的行组问题
【发布时间】:2013-04-27 07:06:29
【问题描述】:

我有一个 Devexpress Xtragrid,我在其中根据特定列对行进行分组。我为 Group 赋予了深蓝色背景色,并将 ShowGroupExpandColpaseButton 也设置为 false。在网格中每个子行的最左侧显示我设置为组背景颜色的颜色。有什么办法可以去除这种颜色吗?

【问题讨论】:

  • 那是组列吧?
  • 是的,隐藏它有什么限制吗?

标签: devexpress xtragrid


【解决方案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;
}

【讨论】:

  • 感谢您的解决方案。这是工作。现在,如果我们分组,网格会在每个子行的开头留下一些额外的空间。有什么办法可以消除这个吗?您能提出一些解决方案吗?
  • @17CrazyBrain 指定level indent如下:gridView1.LevelIndent = 0;
【解决方案2】:

您应该可以通过如下设置从视图中隐藏组:

 this.gridView1.OptionsView.ShowGroupedColumns = false;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多