How to edit an MSFlexgrid
Posted on July 17, 2011
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 'Controls - How to edit an MSFlexgrid Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer) With MSFlexGrid1 Select Case KeyAscii Case 8: 'IF KEY IS BACKSPACE THEN If .Text <> "" Then .Text = _ Left$(.Text, (Len(.Text) - 1)) Case 13: 'IF KEY IS ENTER THEN Select Case .Col Case Is < (.Cols - 1): SendKeys "{right}" Case (.Cols - 1): If (.Row + 1) = .Rows Then .Rows = .Rows + 1 End If SendKeys "{home}" + "{down}" End Select Case Else .Text = .Text + Chr$(KeyAscii) 'write your own keyascii Validations under 'commented lines Select Case .Col Case 0, 1, 2: 'if (your condition(s)) then 'accept only charectors 'Else ' keyascii=0 'End If Case Else: End Select End Select End With End Sub |