in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

FLEXGRID MERGE COLUMNS

Last post 11-30-2007 2:11 PM by C1_GregL. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 08-30-2007 11:12 AM

    FLEXGRID MERGE COLUMNS

    Hi, I have a flexgrid with 6 columns and 3 rows.

     I want to merge the 1° and 2° col, 3° and 4° col and 5°and 6° col

    How i can do that?
     

  • 08-31-2007 12:59 PM In reply to

    • C1_GregL
    • Top 10 Contributor
    • Joined on 06-11-2007
    • Pittsburgh PA
    • Posts 500

    Re: FLEXGRID MERGE COLUMNS

    FlexGrid has the ability to "Allow merging."  That means adjacent cells with similar values can be merged together if the AllowMerging property is True.  This can be done across rows and down columns.

    _flex.AllowMerging = AllowMergingEnum.Free
    ' Merge values in column 1.
    _flex.Cols(1).AllowMerging = True

    Regards,
    Greg L

     

  • 11-22-2007 9:05 PM In reply to

    Re: FLEXGRID MERGE COLUMNS

     

    I'm a newbier in C1.

    How can you show me the way to merger cell in C1FlexGrid in detail?

    My perpose is this picture  

    Merge cellMerge cell

    Thanks 

  • 11-29-2007 12:33 PM In reply to

    Re: FLEXGRID MERGE COLUMNS

    Can anyone help me?
  • 11-30-2007 5:47 AM In reply to

    Re: FLEXGRID MERGE COLUMNS

    Hi !

    Flexgrid can automatically merge adjacent cells  with same content. Your cells in range 0/0 to 3/2 have to contain the same text "Title here".

    Merging is not enabled by default.
    Probably your merged cells are in the fixed area, so simply set "c1FlexGrid.AllowMerging = AllowMergingEnum.FixedOnly".
    Then check that for columns 0-3 "AllowMerging" is TRUE, and same for rows 0-2

    This should do it.

     

    Best regards

     

    Wolfgang

     

  • 11-30-2007 9:30 AM In reply to

    Re: FLEXGRID MERGE COLUMNS

     

    Can you show me in details. I'm a newbie

    I did it but its result didn't as my purpose.

    I Use C1StudioNet_T305 

     My code:

    c1FlexGrid1.Rows.Count = 6;
                c1FlexGrid1.Rows.Fixed = 4;
                c1FlexGrid1.AllowMerging = AllowMergingEnum.FixedOnly;
                c1FlexGrid1.Rows[0].AllowMerging = true;
                c1FlexGrid1.Rows[1].AllowMerging = true;
                c1FlexGrid1.Rows[2].AllowMerging = true;
                c1FlexGrid1.Cols[0].AllowMerging = true;
                c1FlexGrid1.Cols[1].AllowMerging = true;
                c1FlexGrid1.Cols[2].AllowMerging = true;
                c1FlexGrid1.Cols[3].AllowMerging = true;
                c1FlexGrid1[0, 0] = "Title here";
                c1FlexGrid1[0, 1] = "Title here";
                c1FlexGrid1[0, 2] = "Title here";
                c1FlexGrid1[0, 3] = "Title here";
                c1FlexGrid1[1, 0] = "Title here";
                c1FlexGrid1[1, 1] = "Title here";
                c1FlexGrid1[1, 2] = "Title here";
                c1FlexGrid1[1, 3] = "Title here";
                c1FlexGrid1[2, 0] = "Title here";
                c1FlexGrid1[2, 1] = "Title here";
                c1FlexGrid1[2, 2] = "Title here";
                c1FlexGrid1[2, 3] = "Title here";

     

    My result:

  • 11-30-2007 12:16 PM In reply to

    • C1_GregL
    • Top 10 Contributor
    • Joined on 06-11-2007
    • Pittsburgh PA
    • Posts 500

    Re: FLEXGRID MERGE COLUMNS

    To merge rows AND columns you have to override the GetMergedRange method with an inherited flexgrid control.  I attached a sample for you.

     

    Hope that helps,
    Greg L

    Filed under: , , ,
  • 11-30-2007 1:14 PM In reply to

    Re: FLEXGRID MERGE COLUMNS

     

    Thank you so much. But in your project, you use C1.Win.C1FlexGrid.2, which version of C1 do you use?

    In my project, I use C1.Win.C1FlexGrid.C1FlexGrid 

    When I set the fixed row =4

    and I have a "for..." loop to set my merged row, I have a result like picture below:

     

    How can you tell me why?

    I send my project in the link: http://www.yousendit.com/transfer.php?action=batch_download&batch_id=UXlqK0drdGpubHpIRGc9PQ

    Thank you again!! 

     Overview my code:

    fg.Rows.Count = 10;
                fg.Cols.Count = 100;
                fg.Rows.Fixed = 4;
                fg.Cols.Fixed = 0;

                int iCell = 4;

                CellRange rng = new CellRange();
                rng = fg.GetCellRange(0, 0, 2, 3);
                rng.Data = "Title Here";

                string[] str = new string[10];
                for (int i = 0; i < 10; i++)
                {
                    str[i] = "Cell range " + i.ToString();
                }
                for (int i = 0; i < 10; i++)
                {
                    rng = fg.GetCellRange(0, iCell, 0, iCell + 2);
                    rng.Data = str[i];
                    iCell = iCell + 2;
                }

                fg.AllowMerging = AllowMergingEnum.Free;

                for (int i = 0; i <= fg.Cols.Count - 1; i++)
                {
                    fg.Cols[i].AllowMerging = true;
                }

  • 11-30-2007 2:11 PM In reply to

    • C1_GregL
    • Top 10 Contributor
    • Joined on 06-11-2007
    • Pittsburgh PA
    • Posts 500

    Re: FLEXGRID MERGE COLUMNS

    Are you developing in Visual Studio 2003 or 2005?

    If you're using VS2005 then you need to use our 2.0 version (C1.Win.C1FlexGrid.2), which is what I used to create the sample.  Or since you ahve the 1.x version (C1.Win.C1FlexGrid.C1FlexGrid), you should use VS2003.

    It sounds like you are using 2005 but using a .NET 1.X control.  This is probably why the text is screwed up.  I can reproduce this error with this combination.

    You also need to reset iCell back to 4 before the 2nd for loop.

     

    Regards,
    Greg L

Page 1 of 1 (9 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.