Home Forums WinForms controls Xceed Grid for WinForms How to create multiple column headers

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

    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.

    Imported from legacy forums. Posted by Hoa (had 5789 views)

    User (Old forums)
    Member
    Post count: 23064

    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.

    Imported from legacy forums. Posted by Hoa (had 843 views)

    Xceed Support
    Member
    Post count: 5658

    In this other thread, you will find enough informations with the sample on merged cells to get started.

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

    User (Old forums)
    Member
    Post count: 23064

    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?

    Imported from legacy forums. Posted by Dan (had 633 views)

    User (Old forums)
    Member
    Post count: 23064

    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;

    }

     

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

    User (Old forums)
    Member
    Post count: 23064

    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

    Imported from legacy forums. Posted by Hot (had 319 views)

    User (Old forums)
    Member
    Post count: 23064

    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 );

        }

    }

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

    Xceed Support
    Member
    Post count: 5658

    This is a very useful code sample with the amendments Andre and Hoa have posted.  Thanks.  I’ve got it working fine.  There is one more enhancement I would like to add but I cannot work out how.

    As my CustomColumnManagerRow currently behaves, when a scrollable column becomes hidden by being scolled to the left of the FixedColumnSplitter (when there are fixed column of course), its column group header becomes shown above the fixed columns.

    I would like to be able stop the group header title for a group of scrollable columns from being shown above the fixed columns whenever any of the columns in the group are scrolled the left of the FixedColumnSplitter. I cannot see how to do this.  Specifically, what I need to kow is how to detect when a scrollable column becomes hidden by being scolled to the
    left of the FixedColumnSplitter.  I cannot find an event that I could raise to do this.  I would appreciate any suggetions.

    Thanks,
    Simon

    Imported from legacy forums. Posted by Simon (had 744 views)

    User (Old forums)
    Member
    Post count: 23064

    Does anyone know how to go about creating multiple column headers with the latest version (4.0) of Xceed DataGrid for WPF?  I can’t follow the sample code from Xceed’s documentation (see “How to create multiple column headers”) since the current API appears to be significantly different than the one used for this sample code.

    Thanks!

    Imported from legacy forums. Posted by Matt (had 281 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Matt,

    This forum post is for Xceed’s Grid for .Net; please post your question here: http://xceed.com/CS/forums/35/ShowForum.aspx

    Imported from legacy forums. Posted by Alain [Xceed] (had 2254 views)

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