| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2483 人关注过本帖
标题:vb 2005中限定datagridview控件中某列只能数字
只看楼主 加入收藏
skwenl
Rank: 1
等 级:新手上路
帖 子:121
专家分:0
注 册:2007-10-23
结帖率:80%
收藏
 问题点数:0 回复次数:4 
vb 2005中限定datagridview控件中某列只能数字
各位大虾,

 请问在vb 2005中怎么实现 DataGridView控件中某列  (比如第3列)  只能输入数字呢?  谢谢
搜索更多相关主题的帖子: 控件中 datagridview 数字 DataGridView 
2008-07-08 18:48
skwenl
Rank: 1
等 级:新手上路
帖 子:121
专家分:0
注 册:2007-10-23
收藏
得分:0 
晕哦,有哪位大虾能赐教下呢?谢谢.....

2008-07-09 10:30
linxiaokun
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-7-4
收藏
得分:0 
自己參考一下
http://msdn.(VS.80).aspx
2008-07-09 11:26
qlong0728
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:272
专家分:0
注 册:2007-6-15
收藏
得分:0 
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 DataGridView1.CurrentCellAddress.X = 3 Then
            If e.KeyChar <> Chr(46) And e.KeyChar <> Chr(8) And e.KeyChar <> Chr(13) And (e.KeyChar < Chr(48) Or e.KeyChar > Chr(57)) Then
                e.Handled = True
            End If
        End If
    End Sub

程序人员写程序,又拿程序换酒钱。 奔驰宝马贵者趣,公交自行程序员。 不见满街漂亮妹,哪个归得程序员。
2008-07-15 09:32
skwenl
Rank: 1
等 级:新手上路
帖 子:121
专家分:0
注 册:2007-10-23
收藏
得分:0 
谢谢版主,谢谢...

2008-07-17 13:01
快速回复:vb 2005中限定datagridview控件中某列只能数字
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018354 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved