Results 1 to 37 of 37

Thread: Checkbox & keydown [took some time but... RESOLVED!]

Threaded View

  1. #17
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Checkbox & keydown [as yet unserolved]

    Try this - the magic row is #4 and space will check the checkbox
    VB Code:
    1. Private Sub Check1_Click()
    2.     MSFlexGrid1.SetFocus
    3. End Sub
    4.  
    5. Private Sub Form_Load()
    6.     Check1.Visible = False
    7. End Sub
    8.  
    9. Private Sub MSFlexGrid1_EnterCell()
    10.     With MSFlexGrid1
    11.         If .Row = 4 Then
    12.             Check1.Left = .Left + .ColPos(.Col) + (.ColWidth(.Col) - Check1.Width) \ 2
    13.             Check1.Top = .Top + .RowPos(.Row) + (.RowHeight(.Row) - Check1.Height) \ 2
    14.             Check1.Value = Val(.TextMatrix(.Row, .Col))
    15.             Check1.Visible = True
    16.         End If
    17.     End With
    18. End Sub
    19.  
    20. Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
    21.     If MSFlexGrid1.Row = 4 Then
    22.         If KeyAscii = 32 Then Check1.Value = Abs(Not CBool(Check1.Value))
    23.     End If
    24. End Sub
    25.  
    26. Private Sub MSFlexGrid1_LeaveCell()
    27.     With MSFlexGrid1
    28.         If .Row = 4 Then
    29.             .TextMatrix(.Row, .Col) = Check1.Value
    30.             Check1.Visible = False
    31.         End If
    32.     End With
    33. End Sub
    Edit: it also needs this Sub (attachment updated):
    VB Code:
    1. Private Sub MSFlexGrid1_Scroll()
    2.     With MSFlexGrid1
    3.         If Not (.RowIsVisible(.Row) And .ColIsVisible(.Col)) Then
    4.             Check1.Visible = False
    5.         Else[B]If .Row = 4 Then[/B]
    6.             Check1.Left = .Left + .ColPos(.Col) + (.ColWidth(.Col) - Check1.Width) \ 2
    7.             Check1.Top = .Top + .RowPos(.Row) + (.RowHeight(.Row) - Check1.Height) \ 2
    8.             Check1.Visible = True
    9.         End If
    10.     End With
    11. End Sub
    Edit2: another slight change to code (in bold above) - attachment not updated
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width