MSHFlexGrid Not Merging Cells Properly-VBForums
Results 1 to 8 of 8

Thread: MSHFlexGrid Not Merging Cells Properly

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 1999
    Location
    London
    Posts
    44

    MSHFlexGrid Not Merging Cells Properly

    Hey Guys,

    Would somebody help and tell what is wrong with my code bellow, it should merge the cells with the same value?

    vb Code:
    1. Private Sub sub_AddMovie(p_ID, p_Poster, p_Year, p_Title, p_Rating, p_Info)
    2.  
    3.     With fxg_Tomatoes 'MSHFlexGrid
    4.         For vm_Row = 0 To 3 ' WILL ADD 4 NEW ROWS
    5.             .AddItem ""
    6.        
    7.             vm_CurrentRow = .Rows - 1    
    8.             .Row = vm_CurrentRow
    9.             .col = 0        ' COL 0 HOLDS POSTER PICTURE
    10.             .Text = p_ID    ' CELL MUST HAVE A VALUE TO MERGE
    11.             Set .CellPicture = LoadPicture(p_Poster)
    12.            
    13.             .MergeRow(vm_CurrentRow) = True
    14.             .MergeCol(0) = True
    15.             .MergeCol(1) = True
    16.             .MergeCol(2) = True
    17.             .MergeCol(3) = True
    18.            
    19.             Select Case vm_Row
    20.                     Case 0, 1, 2
    21.                         For t = 1 To 3  ' SHOULD MERGE CELLS W SAME VALUES TO MAKE IT ONE LINE (ROW)
    22.                             .col = t
    23.                             .Text = p_Title
    24.                             .CellAlignment = 4
    25.                         Next t
    26.                        
    27.                     Case 3
    28.                         .col = 1
    29.                         .Text = p_Year
    30.                         .CellFontSize = 10
    31.                         .CellAlignment = 4
    32.                        
    33.                         .col = 2
    34.                         .Text = p_Rating
    35.                         .CellFontSize = 10
    36.                         .CellAlignment = 4
    37.                        
    38.                         .col = 3
    39.                         .Text = p_Info
    40.                         .CellFontSize = 10
    41.                         .CellAlignment = 0
    42.             End Select
    43.             DoEvents
    44.         Next vm_Row
    45.         .Refresh
    46.     End With
    47. End Sub

    This is the result:


    I expected to the three cells with text = "Cocoon" to be merged into one cell.

    I've tried changing the the call to .MergeRow(x) and .MergeCol(x) to before changing its values and to after it.. with no effect.

    The .MergeCells property = 1 (free)

    Any help will be welcomed,

    Thanks in advance,
    MBS.
    Last edited by MBS; Feb 6th, 2018 at 09:17 AM.
    MBS

  2. #2
    PowerPoster
    Join Date
    Oct 2013
    Posts
    2,987

    Re: MSHFlexGrid Not Merging Cells Properly

    Is it more complex than this?
    Code:
    Private Sub Form_Load()
      With MSHFlexGrid1
        .Cols = 4
        .Rows = 8
        .FixedCols = 0
        .TextMatrix(0, 0) = "Title"
        .TextMatrix(0, 1) = "Column B"
        .TextMatrix(0, 2) = "Column C"
        .TextMatrix(0, 3) = "Column D"
        .TextMatrix(1, 0) = "Cocoon": .TextMatrix(1, 1) = "B1"
        .TextMatrix(2, 0) = "Cocoon": .TextMatrix(2, 1) = "B2"
        .TextMatrix(3, 0) = "Cocoon": .TextMatrix(3, 1) = "B3"
        .MergeCells = flexMergeFree
        .MergeCol(0) = True
      End With
    End Sub
    
    ' Variant with same title in Columns:
    Private Sub Form_Load()
      With MSHFlexGrid1
        .Cols = 4
        .Rows = 8
        .FixedCols = 0
        .TextMatrix(0, 0) = "Title A"
        .TextMatrix(0, 1) = "Title B"
        .TextMatrix(0, 2) = "Title C"
        .TextMatrix(0, 3) = "Column D"
        .TextMatrix(1, 0) = "Cocoon"
        .TextMatrix(1, 1) = "Cocoon"
        .TextMatrix(1, 2) = "Cocoon"
        .MergeCells = flexMergeFree
        .MergeRow(1) = True
      End With
    End Sub
    Unless you want to merge multiple columns and rows at the same time.
    It's either merging the rows OR merging the columns, not both to create a multi spanned cell.
    Last edited by Arnoutdv; Feb 6th, 2018 at 10:16 AM.

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 1999
    Location
    London
    Posts
    44

    Re: MSHFlexGrid Not Merging Cells Properly

    Hey Arnoutdv, thank you very much for your help. It's the very first time that I'm taking a go with the FlexGrid, so excuse my silliness, but...
    Quote Originally Posted by Arnoutdv View Post

    Is it more complex than this?
    A: Actually yes, it's a little more complex than that, The col(0) that holds the picture is working fine, if I remove the .MergeCol(0) = True it won't merge. Why the same does not apply to the other cols? with or wthout .MergeCol(x) = True it is not merging.

    Unless you want to merge multiple columns and rows at the same time.
    A: Yes that is exactly what I want to do! (sorry if my original post is not clear on that.

    It's either merging the rows OR merging the columns, not both to create a multi spanned cell.
    A: I'm trying this thing based on the MSDN Documentation: Here

    Where it states: Set the MergeRow and MergeCol array properties to True for the rows and columns to be merged.

    Also, if you go to the their sample: Here

    You will find:

    What is exactly what I'm trying to do.

    If I only use the .MergeRow(x) (as per MSDN example) my FlexGrid does not looks like I want, so back to my original question:
    What is wrong with my code?


    Thanks so much again mate.
    MBS

  4. #4
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    925

    Re: MSHFlexGrid Not Merging Cells Properly

    @ MBS,

    you can try if you want my VBFlexGrid control which replaces 100% MSFlexGrid control and most of MSHFlexGrid.
    http://www.vbforums.com/showthread.p...xGrid-control)

    One of the many points fixed and improved is:
    Code:
    - MergeCells can span multiple rows and columns together. (limitation or bug in MSFlexGrid and MSHFlexGrid)

  5. #5
    Fanatic Member ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    964

    Re: MSHFlexGrid Not Merging Cells Properly

    Hi MBS,

    you are making this to difficult, here a sample with just loading a PIVOT Query
    to a FlexGrid.
    take a look at the querys I created in the Database, just change/add values
    here a Image of a Query and shown in the Flexgrid
    Name:  ProductS.jpg
Views: 26
Size:  36.6 KB




    and here the full sample

    Sold.zip

    regards
    Chris
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  6. #6
    PowerPoster
    Join Date
    Oct 2013
    Posts
    2,987

    Re: MSHFlexGrid Not Merging Cells Properly

    Quote Originally Posted by MBS View Post
    Hey Arnoutdv, thank you very much for your help. It's the very first time that I'm taking a go with the FlexGrid, so excuse my silliness, but...
    The sample image only has merged cells in the columns, not in the rows.
    I can not test your code because I have no data to fill it with.

    And I never tested to merge cells with pictures in them.

    Can you post an image what your current grid looks like?

  7. #7

    Thread Starter
    Member
    Join Date
    Jul 1999
    Location
    London
    Posts
    44

    Re: MSHFlexGrid Not Merging Cells Properly

    Sadly, you’ve reached a page that can’t be displayed.

    We’ve logged this action, so we are aware there is an issue!

    At this time, please hit your browser’s back button or simply close this page!

    The incident ID is: N/A.
    Event id: 4888001210706876
    Last edited by MBS; Feb 7th, 2018 at 01:13 PM.
    MBS

  8. #8

    Thread Starter
    Member
    Join Date
    Jul 1999
    Location
    London
    Posts
    44

    Re: MSHFlexGrid Not Merging Cells Properly

    Thanks for your replies guys, but I gave up, in less than 10min I've created an user control (with imagebox, labels and frames) which does the job better than this.

    Quote Originally Posted by Krool View Post
    @ MBS,
    Thanks so much mate,
    I did that (above) before reading your post, now I’m 100% sure I’ve made the right decision.


    you can try if you want my VBFlexGrid control which replaces 100% MSFlexGrid control and most of MSHFlexGrid.
    http://www.vbforums.com/showthread.p...xGrid-control)

    One of the many points fixed and improved is:
    MergeCells can span multiple rows and columns together. (limitation or bug in MSFlexGrid and MSHFlexGrid)
    Quote Originally Posted by ChrisE View Post

    Hi Chris, I don’t see any merged row+col in your sample, I think you missed the point of my original post, but thanks anyway man.

    Hi MBS,
    you are making this to difficult, here a sample with just loading a PIVOT Query
    to a FlexGrid.
    take a look at the querys I created in the Database, just change/add values
    here a Image of a Query and shown in the Flexgrid

    and here the full sample

    regards
    Chris
    Quote Originally Posted by Arnoutdv View Post

    The best result I managed to get is the picture in my original post. But as I said, I gave up. Thanks again for your time man.

    The sample image only has merged cells in the columns, not in the rows.
    I can not test your code because I have no data to fill it with.
    And I never tested to merge cells with pictures in them.
    Can you post an image what your current grid looks like?
    Best Regards you all!

    MBS.
    MBS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width