Home Forums WinForms controls Xceed Grid for WinForms Spanned column headers for detail grid Reply To: Spanned column headers for detail grid

User (Old forums)
Member
Post count: 23064

Well, the problem is that this example was done before the Master Detail feature was added to grid, and it has never been updated since!!!

Here is a new class that should work :

public class CustomColumnManagerRow : Row

  {

    protected CustomColumnManagerRow( CustomColumnManagerRow template )

      : base( template )

    {

      m_columns = template.m_columns;

    }

 

    public CustomColumnManagerRow( RowSelector selector )

      : base( selector ) { }

 

    public CustomColumnManagerRow( int columns )

      : base()

    {

      m_columns = columns;

    }

 

    protected override Xceed.Grid.Row CreateInstance()

    {

      return new CustomColumnManagerRow( this );

    }

 

    protected override void PaintForeground( GridPaintEventArgs e )

    {

      int width = 0;

 

      if( ( this.ParentGrid.DetailGridTemplates.Count > 0 ) && ( this.ParentGrid.SideMargin.Visible ) )

        width += this.ParentGrid.SideMargin.Width;

     

      if( this.ParentGrid.FixedColumnSplitter.Visible )

        width += this.ParentGrid.FixedColumnSplitter.Width;

 

      int lastColumn = 0;

 

      int columnsPerGroup = ( this.ParentGrid.Columns.Count / m_columns );

 

      for( int j = 0; j < m_columns; j++ )

      {

        for( int i = 0; i < columnsPerGroup; i++ )

        {

          width += this.ParentGrid.Columns[ lastColumn ].Width;

          lastColumn++;

        }

 

        e.Graphics.DrawLine( this.GridControl.GridLinePen, e.DisplayRectangle.X + width – 1, 0,

                             e.DisplayRectangle.X + width – 1, this.Height );

      }

    }

 

    protected override int GetFittedDisplayHeight( AutoHeightMode mode, Graphics graphics, bool printing )

    {

      int fittedDisplayHeight = base.GetFittedDisplayHeight( mode, graphics, printing );

 

      return ( fittedDisplayHeight < 16 ) ? 16 : fittedDisplayHeight;

    }

 

    protected override int DefaultHeight

    {

      get { return 16; }

    }

 

    protected override bool DefaultCanBeCurrent

    {

      get { return false; }

    }

 

    public override bool IsBackColorAmbient

    {

      get { return false; }

    }

 

    protected override System.Drawing.Color DefaultBackColor

    {

      get { return SystemColors.Control; }

    }

 

    private int m_columns = 0;

  }

Let us know if it does what you want.

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