Hugh
Thanks have used your ideas as basis for my row grouping of
msflexigrid Data
see below
'__________________
Option Explicit
' variable to hold our selected rows
Private LGridColour As Long
Private LActiveColour As Long
Private LFLagColour As Long
Private LngWork As Long
Private LngTemp As Long
Private StrWork As String
Private IBeginRow As Integer
Private IEndRow As Integer
Private CtrlPressed As Boolean
Private Sub Form_Load()
Dim lCol As Long, lRow As Long
CtrlPressed = False
' initialise the grid
With MSFlexGrid1
.Redraw = False
.Cols = 8
.Rows = 10
' AT SOME STAGE BEFORE USE
' Set LGridColour = to Normal CellbackColor of Grid
' then make LFLagColour some other colour
' So That It Stands
' out when Row Clicked
.Row = 1
LGridColour = .CellBackColor
If LGridColour = vbRed Then
LFLagColour = vbWhite
Else
LFLagColour = vbRed
End If
.AllowBigSelection = False
.SelectionMode = flexSelectionFree
' fill the grid with some data
For lRow = .FixedRows To .Rows - 1
.TextMatrix(lRow, 0) = "Row: " & lRow
For lCol = .FixedCols To .Cols - 1
.TextMatrix(lRow, lCol) = "R" & lRow & "C" & lCol
Next lCol
Next lRow
'
.Redraw = True
End With
End Sub
Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
' going to check whether a (new) row is selected
' If CTRL is pressed we decide if it is
' Start Of Group Of Rows
' colour the line OPPOSITE To What It Is
' Or
' the End Row Of Group
' Colour All Lines
' Same Colour as Start Row Of Group
' Else
' colour the line OPPOSITE To What It Is
' Clear Begin Group
Dim IReturnToRow As Integer
Dim IReturnToCol As Integer
If CtrlPressed = False Then IBeginRow = 0
With MSFlexGrid1
IReturnToRow = .MouseRow
IReturnToCol = .MouseCol
If .MouseRow > 0 Then
If Shift = vbCtrlMask Then
If CtrlPressed = False Then
.Row = .MouseRow
.Col = 1
IBeginRow = .Row
IEndRow = .Row
CtrlPressed = True
If .CellBackColor = LFLagColour Then
LActiveColour = LGridColour
Else
LActiveColour = LFLagColour
End If
PaintTheRows
IEndRow = 0
Else
If IBeginRow > 0 Then
.Row = .MouseRow
IEndRow = .Row
PaintTheRows
CtrlPressed = False
IBeginRow = 0
IEndRow = 0
LActiveColour = LGridColour
End If
End If
Else
.Row = .MouseRow
.Col = 1
IBeginRow = .Row
IEndRow = .Row
If .CellBackColor = LFLagColour Then
LActiveColour = LGridColour
Else
LActiveColour = LFLagColour
End If
PaintTheRows
CtrlPressed = False
IBeginRow = 0
IEndRow = 0
LActiveColour = LGridColour
End If
End If
.Row = IReturnToRow
.Col = IReturnToCol
End With
End Sub
Sub PaintTheRows()
With MSFlexGrid1
.Redraw = False
.FillStyle = flexFillRepeat
.Col = 1
.Row = IBeginRow
.ColSel = .Cols - 1
.RowSel = IEndRow
.CellBackColor = LActiveColour
.FillStyle = flexFillSingle
.Redraw = True
.Refresh
End With
End Sub