I have a program and need to select multible cells in a HSHFlexGrid.
I have it working the the folloing code with some issues
Here is what I want I want to select mulitble cells but only one cell per col I must be able to know what cells are picked later.
The problems are is there a better way to set the cellbackcolor? Stepping thou all cells take long on some larger grids. I have the backcollor changed depending on what is in there so I can not globaly set all backcolor.
Is there a better way to do what I am trying?
Is there a faster way to clear the cell backcolor?
VB Code:
Dim multi As Boolean Dim TargetSelect(200) As Integer ' max cols possible Private Sub MSHFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) ' do not want row or col 0 If MSHFlexGrid1.MouseCol > 0 And MSHFlexGrid1.MouseRow > 0 Then If Button = vbLeftButton Then Dim lngColor As Long If Shift = vbCtrlMask Then ' Only one want cell allowed per col If TargetSelect(MSHFlexGrid1.Col) < 1 Then lngColor = MSHFlexGrid1.BackColor If MSHFlexGrid1.CellBackColor = MSHFlexGrid1.BackColor Then lngColor = MSHFlexGrid1.BackColorSel TargetSelect(MSHFlexGrid1.Col) = 0 End If With MSHFlexGrid1 .CellBackColor = lngColor ' save what cell is marked in this col TargetSelect(.Col) = .Row End With mulit = True End If Else If multi = True Then lngColor = MSHFlexGrid1.BackColor With MSHFlexGrid1 tmprow = .Row tmpcol = .Col ' Take too long! For a = 1 To .Cols - 1 .Col = a TargetSelect(.Col) = 0 For b = 1 To .Rows - 1 .Row = b If .CellBackColor = .BackColorSel Then ' Set all cell back to normal .CellBackColor = lngColor End If Next b Next a .Row = tmprow .Col = tmpcol End With End If lngColor = MSHFlexGrid1.BackColor If MSHFlexGrid1.CellBackColor = MSHFlexGrid1.BackColor Then lngColor = MSHFlexGrid1.BackColorSel TargetSelect(MSHFlexGrid1.Col) = 0 End If With MSHFlexGrid1 .CellBackColor = lngColor TargetSelect(.Col) = .Row End With multi = True End If End If End If End Sub




Reply With Quote