-
Feb 6th, 2018, 09:04 AM
#1
Thread Starter
Lively Member
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:
Private Sub sub_AddMovie(p_ID, p_Poster, p_Year, p_Title, p_Rating, p_Info) With fxg_Tomatoes 'MSHFlexGrid For vm_Row = 0 To 3 ' WILL ADD 4 NEW ROWS .AddItem "" vm_CurrentRow = .Rows - 1 .Row = vm_CurrentRow .col = 0 ' COL 0 HOLDS POSTER PICTURE .Text = p_ID ' CELL MUST HAVE A VALUE TO MERGE Set .CellPicture = LoadPicture(p_Poster) .MergeRow(vm_CurrentRow) = True .MergeCol(0) = True .MergeCol(1) = True .MergeCol(2) = True .MergeCol(3) = True Select Case vm_Row Case 0, 1, 2 For t = 1 To 3 ' SHOULD MERGE CELLS W SAME VALUES TO MAKE IT ONE LINE (ROW) .col = t .Text = p_Title .CellAlignment = 4 Next t Case 3 .col = 1 .Text = p_Year .CellFontSize = 10 .CellAlignment = 4 .col = 2 .Text = p_Rating .CellFontSize = 10 .CellAlignment = 4 .col = 3 .Text = p_Info .CellFontSize = 10 .CellAlignment = 0 End Select DoEvents Next vm_Row .Refresh End With 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
-
Feb 6th, 2018, 10:09 AM
#2
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.
-
Feb 6th, 2018, 01:05 PM
#3
Thread Starter
Lively Member
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...
Originally Posted by Arnoutdv
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.
-
Feb 6th, 2018, 01:44 PM
#4
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)
-
Feb 7th, 2018, 03:22 AM
#5
Re: MSHFlexGrid Not Merging Cells Properly
Originally Posted by MBS
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?
-
Feb 7th, 2018, 01:17 PM
#6
Thread Starter
Lively Member
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.
Originally Posted by Krool
@ 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)
Originally Posted by ChrisE
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
Originally Posted by Arnoutdv
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.
-
Feb 7th, 2018, 02:50 AM
#7
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
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.
-
Feb 7th, 2018, 01:05 PM
#8
Thread Starter
Lively Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|