[RESOLVED] Can I merge cells in MSFlexGrid without merging cols below???
I want to merge som cells in my top row, in a flexgrid. How do I do that, without merging the columns below?
l--------------l
l--------------l
l--l--l--l--l--l--l
l--l--l--l--l--l--l
l--l--l--l--l--l--l
l--l--l--l--l--l--l
l--l--l--l--l--l--l
Have a nice weekend! :) :) :)
Steff
Re: Can I merge cells in MSFlexGrid without merging cols below???
You might have the wrong idea of what a merge cell is in a flexgrid. From MSDN.
Quote:
Returns or sets a value that determines whether cells with the same contents should be grouped in a single cell spanning multiple rows or columns.
That means if you have 100 in one cell, and 100 in the cell next to it, it will be merged, and 100 will only appear once.
Here is some more on it's use:
Quote:
Syntax
object.MergeCells [=value]
The MergeCells property syntax has these parts:
Part Description
object Anobject expression that evaluates to an object in the Applies To list.
value An integer orconstant that specifies the grouping (merging) of cells, as specified in Settings.
Settings
The settings for value are:
Constant Value Description
flexMergeNever 0 Never. The cells containing identical content are not grouped. This is the default.
flexMergeFree 1 Free. Cells with identical content always merge.
flexMergeRestrictRows 2 Restrict Rows. Only adjacent cells (to the left of the current cell) within the row containing identical content merge.
flexMergeRestrictColumns 3 Restrict Columns. Only adjacent cells (to the top of the current cell) within the column containing identical content merge.
flexMergeRestrictBoth 4 Restrict Both. Only adjacent cells within the row (to the left) or column (to the top) containing identical content merge.
Remarks
The ability to merge cells enables you to present data in a clear, concise manner. You can use cell merging in conjunction with the sorting and column order functions of the MSHFlexGrid.
To use the cell merging capabilities of the MSHFlexGrid:
Set MergeCells to a value other than zero. (The difference between the settings is explained in the example.)
Set the MergeRow and MergeCol array properties to True for the rows and columns to be merged.
When using the cell merging capabilities, the MSHFlexGrid merges cells with identical content. The merging is automatically updated whenever the cell content changes.
When MergeCells is set to a value other than 0 (Never), selection highlighting is automatically turned off. This is done to speed up repainting, and because selection of ranges containing merged cells may lead to unexpected results.
Re: Can I merge cells in MSFlexGrid without merging cols below???
I was making a timeline with each cell as 5 minutes, and a fixed row with hour as text...
------------l-----------------------------l-----------
l................l.....................00 hrs............l.........01 hrs
------------l-----------------------------l-----------
l--l--l--l--l--l--l--l--l--l--l--l--l--l--l--l--l--l--l--l--l--l--l
This worked:
VB Code:
For x = 5 To MSFlexGrid2.Cols - 1
MSFlexGrid2.ColWidth(x) = 100
Next
x = 5
y = 0
z = 0
For x = 5 To MSFlexGrid2.Cols - 1
For y = 0 To 23
For z = 0 To 11
.TextMatrix(0, x + z) = Format(y, "00") & " hrs"
Next
x = x + 12
Next
Next
.MergeCells = flexMergeRestrictColumns
.MergeRow(0) = True