程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> .NET實例教程 >> 制datagridview單元格只能輸入數字 VB2005(收藏)

制datagridview單元格只能輸入數字 VB2005(收藏)

編輯:.NET實例教程
Public EditCell As DataGridVIEwTextBoxEditingControl

    Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridVIEw1.EditingControlShowing
        EditCell = CType(e.Control, DataGridVIEwTextBoxEditingControl)
        EditCell.SelectAll()
        AddHandler EditCell.KeyPress, AddressOf Cells_KeyPress
    End Sub

    Private Sub Cells_KeyPress(ByVal sender As System.Object, ByVal e As KeyPressEventArgs)
        If e.KeyChar <> Chr(8) And e.KeyChar <> Chr(13) And (e.KeyChar < Chr(48) Or e.KeyChar > Chr(57)) Then
                Beep()
                Beep()
                e.KeyChar = Chr(0)
        End If
    End Sub
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved