Home Forums WinForms controls Xceed Grid for WinForms Hiding columns that are being grouped by

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15226 |

    Is there an easy way to prevent a column from being displayed when it has been dragged into the GroupByRow? I only want to see it in the group header.

    Imported from legacy forums. Posted by Ken (had 2335 views)

    User (Old forums)
    Member
    Post count: 23064

    You could try this (untested code):
    grid.GroupingUpdated += new EventHandler(grid_GroupingUpdated);
    void grid_GroupingUpdated(object sender, EventArgs e)
    {
    List<string> lListGroupColumns = new List<string>();
    foreach(Group g in grid.GroupTemplates)
    if (!string.IsNullOrEmpty(g.GroupBy))
    lListGroupColumns.Add(g.GroupBy);

    foreach(Column c in grid.Columns)
    c.Visible = !lListGroupColumns.Contains(c.FieldName);
    }

    Imported from legacy forums. Posted by Tommy (had 320 views)

    User (Old forums)
    Member
    Post count: 23064

    Works like a charm. Here is the VB.NET (fully tested) version for anyone who’s interested.

    Thanks!
    Ken

    Private Sub grdRecords_GroupingUpdated(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdRecords.GroupingUpdated

    Dim GroupByColumns As New ArrayList

    For Each g As Xceed.Grid.Group In Me.grdRecords.GroupTemplates
    If Not String.IsNullOrEmpty(g.GroupBy) Then
    GroupByColumns.Add(g.GroupBy)
    End If
    Next

    For Each c As Xceed.Grid.Column In Me.grdRecords.Columns
    c.Visible = Not GroupByColumns.Contains(c.FieldName)
    Next

    End Sub

    Imported from legacy forums. Posted by Ken (had 3423 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.