Welcome to the Xceed Community | Help
Community Search  

How to create multiple column headers

Sort Posts: Previous Next
  •  03-07-2008, 7:39 AM Post no. 3300

    How to create multiple column headers

    I found this in the documentation however it doesn't work when I tried the code.

    - The CustomColumnManagerRow class is built error
    e.Graphics.DrawLine(this.ParentGrid.GridLinePen, e.DisplayRectangle.X + width - 1, 0,
    e.DisplayRectangle.X + width - 1, this.Height);
    causes an error message: "Error 1 'Xceed.Grid.DetailGrid' does not contain a definition for 'GridLinePen' and no extension method 'GridLinePen' accepting a first argument of type 'Xceed.Grid.DetailGrid' could be found (are you missing a using directive or an assembly reference?)".

    - So I change that line of code to
    e.Graphics.DrawLine(this.GridControl.GridLinePen, e.DisplayRectangle.X + width - 1, 0,
    e.DisplayRectangle.X + width - 1, this.Height);

    The class could be compiled succesfully but I could not see the multiple column headers as it is in the documentation.

    Please ask me if you have any questions. Thanks in advance.
  •  03-07-2008, 8:05 PM Post no. 3301 in reply to 3300

    Re: How to create multiple column headers

    Link to this http://doc.xceedsoft.com/products/XceedGrid/How_to_create_multiple_column_headers.html

    I see it is possible to merge cells in a DataRow but I don't know whether it is possible to create a multiple-row and multiple-column grid header in which a header cell could be merged with its neighbor cells.

    Thanks for any helps.
  •  03-12-2008, 4:57 PM Post no. 3302 in reply to 3301

    Re: How to create multiple column headers

    In this other thread, you will find enough informations with the sample on merged cells to get started.
    Charles Bérubé-Rémillard
    Technical Support
    Xceed Software Inc.
  •  10-10-2008, 1:44 AM Post no. 16006 in reply to 3302

    Re: How to create multiple column headers

    when you run the sample http://doc.xceedsoft.com/products/XceedGrid/How_to_create_multiple_column_headers.html the header row DOES NOT display. However, if you change it a ValueRow it will display. Only difference is you arent merged cells at this point.   Why doesnt the code work like the image on the page?
  •  10-14-2008, 4:34 PM Post no. 16094 in reply to 16006

    Re: How to create multiple column headers

    In fact, it still works, except that the new header rows have a height of 1, which means you don't see them.  The reason for this is that there was a change in the methods and properties used, and DefaultHeight is not consulted anymore.  So you need to override GetFittedDisplayHeight to make it work.

    You can add the following to the existing code, and you will see the rows appear.

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

    {

        return this.DefaultHeight;

    }

     


    André
    Software Developer and Tech Support
    Xceed Software Inc.
  •  11-16-2008, 10:42 PM Post no. 16917 in reply to 16094

    Re: How to create multiple column headers

    Hello, I try your method and see the headers, but there aren't Column name on it,i want to know weather add name on it ,and weather they are real column?

    thanks very much

  •  11-17-2008, 12:26 PM Post no. 16942 in reply to 16917

    Re: How to create multiple column headers

    No, they are not real columns, it is only a way of grouping columns together under common headers.

    You need to add a custom text to each cell of these headers yourself.  You need to do this in the PaintForeground.

    e.g. :

    protected override void PaintForeground( GridPaintEventArgs e )

    {

        int width = 0;

        int lastColumn = 0;

        for( int j = 0; j < this.GridControl.Columns.Count / m_columns; j++ )

        {

            //this is where we set the text of the new grouped column

            e.Graphics.DrawString( "some grouped column", GridControl.Font, new System.Drawing.SolidBrush( Color.Black ), new Point( e.DisplayRectangle.X + width, e.DisplayRectangle.Y ) );

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

            {

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

                lastColumn++;

            }

            e.Graphics.DrawLine( this.GridControl.GridLinePen, e.DisplayRectangle.X + width - 1, 0, e.DisplayRectangle.X + width - 1, this.Height );

        }

    }


    André
    Software Developer and Tech Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.