Re: Help doing this with MSHFlexgrid???

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Not sure about that left button delete but... use the mouse to select a
few cells and hit the delete key.
'===========
Option Explicit

............<<snip>>............

Private Sub MSFlexGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
Dim iRow As Integer
Dim iCol As Integer
Dim iRowStep As Integer
Dim iColStep As Integer

If KeyCode = vbKeyDelete Then
With MSFlexGrid1
If .RowSel < .Row Then
iRowStep = -1
Else
iRowStep = 1
End If
If .ColSel < .Col Then
iColStep = -1
Else
iColStep = 1
End If
For iRow = .Row To .RowSel Step iRowStep
For iCol = .Col To .ColSel Step iColStep
.TextMatrix(iRow, iCol) = ""
Next
Next
'clear the selection
.RowSel = .Row
.ColSel = .Col
End With
End If

End Sub
'===========

I can shorten up that KeyDown code a little bit for you...

Private Sub MSFlexGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
Dim OriginalFillStyle As Long
If KeyCode = vbKeyDelete Then
With MSFlexGrid1
OriginalFillStyle = .FillStyle
.FillStyle = flexFillRepeat
.Text = ""
.FillStyle = OriginalFillStyle
'clear the selection
.Row = .Row
End With
End If
End Sub


Rick


.


Quantcast