Home Forums WinForms controls Xceed Grid for WinForms Hide Group Expand/Collapse Control Reply To: Hide Group Expand/Collapse Control

User (Old forums)
Member
Post count: 23064

There is no property you can set for this.  You will need to create your own GroupManagerRow, and override PaintForeground and OnClick() to accomplish this.

e.g.:

public class CustomGroupManagerRow : GroupManagerRow

{

    // Initializes a new instance of the CustomGroupManagerRow class specifying the

    // template that will be used to create group manager rows.

    public CustomGroupManagerRow( CustomGroupManagerRow template )

        :

base( template )

    {

    }

    public CustomGroupManagerRow()

    {

    }

    // Creates a clone of the CustomGroupManagerRow.

    protected override Row CreateInstance()

    {

        return new CustomGroupManagerRow( this );

    }

    // Paints the foreground of the CustomGroupManagerRow without

    //the +/- icon

    protected override void PaintForeground(GridPaintEventArgs e)

    {

        Rectangle

m_buttonRectangle = new Rectangle( 0, 0, 0, 0 );

        //e.Graphics includes the expand/collapse button, so by using a 0 size rectangle, it will not be painted

        this.Theme.PaintGroup( e.Graphics, m_buttonRectangle, new GroupUIState( 0 ), 0 );

    }

    //Handle the click so it does not do anything.

    protected override void OnClick( EventArgs e )

    {

    }

}

 

Then use this in your code :

private void Form1_Load(object sender, System.EventArgs e)

{

    Group group1 = new Group();

    group1.GroupBy =

“City”;

    CustomGroupManagerRow groupManagerRow1 = new CustomGroupManagerRow();

    group1.HeaderRows.Add( groupManagerRow1 );

    gridControl1.GroupTemplates.Add( group1 );

}

Or use the GroupAdded event so the same GroupManagerRow template is used when the user drags a column to the GroupByRow :

private void Form1_Load(object sender, System.EventArgs e)

{

    gridControl1.GroupAdded +=

new GroupAddedEventHandler(gridControl1_GroupAdded);

}

private void gridControl1_GroupAdded(object sender, GroupAddedEventArgs e)

{

   

CustomGroupManagerRow groupManagerRow1 = new CustomGroupManagerRow();

    e.Group.HeaderRows.Clear();

    e.Group.HeaderRows.Add( groupManagerRow1 );

}

 

Imported from legacy forums. Posted by André (had 876 views)