Home Forums WinForms controls Xceed Grid for WinForms Grouping Question

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

    I have a grid setup with 5 columns. The grid is grouped by Column1 and Column1 is set to invisible. Now I want to add a button that let the users remove the grouping and another button to regroup the grid by Column1. How do I do that?

    Thanks

    Imported from legacy forums. Posted by Paul (had 1915 views)

    Xceed Support
    Member
    Post count: 5658

    Here is a snippet of code that should help you get started (I added a GridControl and 2 Buttons to my form):

    <code>
    private void Form1_Load( object sender, EventArgs e )
    {
    Column col1 = new Column( “Column1” );
    Column col2 = new Column( “Column2” );
    Column col3 = new Column( “Column3” );
    Column col4 = new Column( “Column4” );
    Column col5 = new Column( “Column5” );
    gridControl1.Columns.Add( col1 );
    gridControl1.Columns.Add( col2 );
    gridControl1.Columns.Add( col3 );
    gridControl1.Columns.Add( col4 );
    gridControl1.Columns.Add( col5 );

    for( int i = 0; i < 30; i++ )
    {
    Xceed.Grid.DataRow row = gridControl1.DataRows.AddNew();
    foreach( Cell cell in row.Cells )
    {
    cell.Value = “Item ” + (i%5).ToString() + ” : ” + cell.ParentColumn.Title;
    }
    row.EndEdit();
    }

    gridControl1.Columns[ “Column1” ].Visible = false;
    }

    private void butGroup_Click( object sender, EventArgs e )
    {
    Group groupCol1 = new Group();
    groupCol1.GroupBy = “Column1”;

    groupCol1.HeaderRows.Add( new GroupManagerRow() );

    gridControl1.GroupTemplates.Add( groupCol1 );
    gridControl1.UpdateGrouping();
    }

    private void butUnGroup_Click( object sender, EventArgs e )
    {
    gridControl1.GroupTemplates.Clear();
    gridControl1.UpdateGrouping();
    }
    </code>

    Imported from legacy forums. Posted by CharlesB (had 3142 views)

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