Home > How-To Library > Controls

How to edit an MSFlexgrid

**************************************************************** * © 2007 CodeItBetter http://www.codeitbetter.com * * This notice MUST stay intact for legal use * ****************************************************************
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

If you would like to submit your code here please us. Do not forget to mention your name. We are always thankful to each and everyone of you who submitted their code here.