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

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

    I need to generate a column header on top of the regular header that spans multiple columns in a detail grid.  I checked out the example of group column headers and it doesn’t seem to work in a detail grid.  Any ideas?

     Thanks

    Imported from legacy forums. Posted by Bernard (had 2542 views)

    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)

    User (Old forums)
    Member
    Post count: 23064

    Ok now the example works.  Now on to my next nuance.  The detail grid consists of columns in 3 groups (hence three super headings using this example).  However the first and 3rd group can have columns either not visible or in a different order via the visibleindex property.

    How do I calculate the  the width for these 3 sections so that this CustomColumnMnagerRow can display headers for the 3 sections?  Each of the sections has an absolute contiguous ranges of column number (original define order).  So basically I hand the first super header to cover columns in the range 0-9, 2nd 10-15, 3rd 16 – 25.  As mentioned above, some of the columns in the first and 3rd section may either not be visible or in a different order within the section (never across sections).

     Thanks,

    Bernie

    Imported from legacy forums. Posted by Bernard (had 484 views)

    User (Old forums)
    Member
    Post count: 23064

    The class we provided is only an example, it is not a feature of the grid.

    You will need to calculate yourself the width of the sections while verifying if columns are visible or not, and so on…

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

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