zoukankan      html  css  js  c++  java
  • DataGirdView 单元格限制内容输入参考(按键时的判断)

    限制DataGridView的输入

    DataGridView
     1     '******************************************************************************************
    2 ''' <summary>AddHandler DGV key press</summary>
    3 Private Sub DGV_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dgvMain.EditingControlShowing
    4 Try
    5 Dim CurEditrCell As DataGridViewTextBoxEditingControl
    6
    7 If TypeOf e.Control Is DataGridViewTextBoxEditingControl Then
    8 CurEditrCell = CType(e.Control, DataGridViewTextBoxEditingControl)
    9 AddHandler CurEditrCell.KeyPress, AddressOf dgvKeyPress
    10 End If
    11 Catch ex As Exception
    12
    13 End Try
    14 End Sub
    15
    16 '******************************************************************************************
    17 ''' <summary>DGV Cell key press event</summary>
    18 Private Sub dgvKeyPress(ByVal sender As System.Object, ByVal e As KeyPressEventArgs)
    19 Try
    20 With dgvMain
    21 If .CurrentCell Is Nothing Then
    22 Exit Sub
    23 End If
    24
    25 If (Asc(e.KeyChar) <> Keys.Back) Then
    26 Select Case .CurrentCell.ColumnIndex
    27 Case 2, 3
    28 If (sender.text.length < 10) Then
    29 If (e.KeyChar <> Chr(47)) AndAlso ((e.KeyChar > Chr(57)) OrElse (e.KeyChar < Chr(48))) Then
    30 e.Handled = True
    31 End If
    32 Else
    33 e.Handled = True
    34 End If
    35 End Select
    36 End If
    37
    38 End With
    39 Catch ex As Exception
    40
    41 End Try
    42 End Sub



  • 相关阅读:
    JBoss+MyEclipse+Mysql 的J2EE环境配置。
    编写一个Session EJB
    编写一个MDB (Message Drive Bean)
    轻便的客户端本地文件数据库 SQLite
    SSH(Struts+Spring+Hibernate)Summary/Profile
    Linux test命令
    mysql权限相关
    linux shell 查看进程的可执行程序路径
    添加dns
    Linux的shell变量
  • 原文地址:https://www.cnblogs.com/sugartomato/p/2303860.html
Copyright © 2011-2022 走看看