تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
كيف امنع كتابة الحروف في DataGridView
#2
كود :
Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing        Dim TextEdit As TextBox = e.Control
        RemoveHandler TextEdit.KeyPress, AddressOf TextBox_KeyPress_Number
        AddHandler TextEdit.KeyPress, AddressOf TextBox_KeyPress_Number
    End Sub


    Public Sub TextBox_KeyPress_Number(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
        Dim KeyAscii As Short = Asc(e.KeyChar)
        Select Case KeyAscii
            Case 48, 49, 8
                e.Handled = False
            Case Else
                e.Handled = True
        End Select
        ' 48 is KeyAscii for Number 0
        ' 49 is KeyAscii for Number 1
        ' 8 is KeyAscii for Back Key
    End Sub
(وَقُل رَّبِّ زِدْنِي عِلْمًا)

الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
كيف امنع كتابة الحروف في DataGridView - بواسطة kslawy - 20-12-12, 10:51 PM


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم