Jak psßt do bun∞k MSFlexGrid

 

 

 

Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)

Select Case KeyAscii
    Case vbKeyReturn
    ' po stisku Enteru se prejde na dalsi bunku
      With MSFlexGrid1
         If .Col + 1 <= .Cols - 1 Then
           .Col = .Col + 1
         ElseIf .Row + 1 <= .Rows - 1 Then
           .Row = .Row + 1
           .Col = 0
         Else
           .Row = 1
           .Col = 0
         End If
      End With
    Case vbKeyBack
    ' smazani znaku po stiknuti BackSpace
      With MSFlexGrid1
         If Trim(.Text) <> "" Then _
           .Text = Mid(.Text, 1, Len(.Text) - 1)
         End With
    Case Is < 32
    ' Pryc ze znaky, ktere nelze zobrazit
    Case Else ' jinak zobraz co muzes
      With MSFlexGrid1
         .Text = .Text & Chr(KeyAscii)
      End With
    End Select
End Sub

Private Sub MSFlexGrid1_KeyUp(KeyCode As Integer, Shift As Integer)

Select Case KeyCode
   ' Copy
   Case vbKeyC And Shift = 2 ' Control + C
      Clipboard.Clear
      Clipboard.SetText FlxGrdDemo.Text
      KeyCode = 0
   ' Paste
   Case vbKeyV And Shift = 2 'Control + V
      MSFlexGrid1.Text = Clipboard.GetText
      KeyCode = 0
   ' Cut
   Case vbKeyX And Shift = 2 'Control + X
      Clipboard.Clear
      Clipboard.SetText FlxGrdDemo.Text
      MSFlexGrid1.Text = ""
      KeyCode = 0
   ' Delete
   Case vbKeyDelete
      MSFlexGrid1.Text = ""
End Select

End Sub