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:
  1. Dim multi As Boolean
  2. Dim TargetSelect(200) As Integer  ' max cols possible
  3.  
  4. Private Sub MSHFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  5. ' do not want row or col 0
  6. If MSHFlexGrid1.MouseCol > 0 And MSHFlexGrid1.MouseRow > 0 Then
  7.     If Button = vbLeftButton Then
  8.         Dim lngColor As Long
  9.         If Shift = vbCtrlMask Then
  10.            ' Only one want cell allowed per col
  11.            If TargetSelect(MSHFlexGrid1.Col) < 1 Then
  12.                 lngColor = MSHFlexGrid1.BackColor
  13.                 If MSHFlexGrid1.CellBackColor = MSHFlexGrid1.BackColor Then
  14.                     lngColor = MSHFlexGrid1.BackColorSel
  15.                     TargetSelect(MSHFlexGrid1.Col) = 0
  16.                 End If
  17.                 With MSHFlexGrid1
  18.                     .CellBackColor = lngColor
  19.                      ' save what cell is marked in this col
  20.                     TargetSelect(.Col) = .Row
  21.                 End With
  22.                 mulit = True
  23.             End If
  24.            
  25.         Else
  26.             If multi = True Then
  27.               lngColor = MSHFlexGrid1.BackColor      
  28.               With MSHFlexGrid1
  29.                 tmprow = .Row
  30.                 tmpcol = .Col
  31.                 ' Take too long!
  32.                 For a = 1 To .Cols - 1
  33.                     .Col = a
  34.                     TargetSelect(.Col) = 0
  35.                     For b = 1 To .Rows - 1
  36.                         .Row = b
  37.                         If .CellBackColor = .BackColorSel Then
  38.                             ' Set all cell back to normal
  39.                             .CellBackColor = lngColor
  40.                         End If
  41.                     Next b
  42.                 Next a
  43.                 .Row = tmprow
  44.                 .Col = tmpcol
  45.               End With
  46.            End If
  47.            
  48.            lngColor = MSHFlexGrid1.BackColor
  49.    
  50.            If MSHFlexGrid1.CellBackColor = MSHFlexGrid1.BackColor Then
  51.                 lngColor = MSHFlexGrid1.BackColorSel
  52.                 TargetSelect(MSHFlexGrid1.Col) = 0
  53.            End If
  54.    
  55.            With MSHFlexGrid1
  56.                 .CellBackColor = lngColor
  57.                 TargetSelect(.Col) = .Row
  58.            End With
  59.            
  60.            multi = True
  61.        
  62.         End If
  63.    
  64.     End If
  65.  
  66. End If
  67. End Sub