找回密码
 立即注册

QQ登录

只需一步,快速开始

zgblxy

注册会员

3

主题

25

帖子

145

积分

注册会员

积分
145
最新发帖
zgblxy
注册会员   /  发表于:2019-6-20 09:49  /   查看:6462  /  回复:18
本帖最后由 zgblxy 于 2019-6-20 09:52 编辑

我的代码是这样的,感觉没有错,请大神指教!
Private Sub txtShoBunruiCD_KeyDown(sender As Object, e As KeyEventArgs) Handles txtShoBunruiCD.KeyDown
        If e.KeyCode = Keys.Enter Then
            txtShoBunruiCD.Text = vbNullString
            MessageBox.Show("1")
        ElseIf txtShoBunruiCD.TextLength <> 3 Then
            MessageBox.Show("2")
        End If
    End Sub

18 个回复

倒序浏览
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-6-20 12:30:57
沙发
我看你的这个方面名称是txtShoBunruiCD_KeyDown

这个你应该绑定的是KeyDown事件吧,并不是enter事件
回复 使用道具 举报
zgblxy
注册会员   /  发表于:2019-6-20 14:24:01
板凳
是的,cellenter在multirow中应该怎么用呢,我用了这个事件,但是我一点击单元格就直接触发了。没有enter键的事了
回复 使用道具 举报
zgblxy
注册会员   /  发表于:2019-6-20 14:33:37
地板
下边是我的代码,麻烦您帮忙看看,为什么cellenter不行呢。
Private Sub mgrdMeisaiList_CellEnter(ByVal sender As Object, ByVal e As CellEventArgs) Handles mgrdMeisaiList.CellEnter

        If Not sender.ContainsFocus Then
            Return
        End If

        Dim shuiru As Double
        Dim shuiba As Double

        shuiru = mgrdMeisaiList.Rows(0).Cells(3).Value
        shuiba = mgrdMeisaiList.Rows(0).Cells(4).Value
        If mgrdMeisaiList.Rows(0).Cells(3).Value = vbNull OrElse mgrdMeisaiList.Rows(0).Cells(3).Value = 0 Then
            MessageBox.Show("12")
            mgrdMeisaiList.Rows(0).Cells(4).Enabled = False
            Return
        End If
        shuiba = shuiru / 1.08
        mgrdMeisaiList.Rows(0).Cells(4).Value = shuiba
        If mgrdMeisaiList.Rows(0).Cells(4).Value = vbNull OrElse mgrdMeisaiList.Rows(0).Cells(4).Value = 0 Then
            MessageBox.Show("1.")
            mgrdMeisaiList.Rows(0).Cells(3).Enabled = False
            Return
        End If
        shuiru = shuiba * 0.08
        mgrdMeisaiList.Rows(0).Cells(3).Value = shuiru
    End Sub
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-6-20 17:14:12
5#
你好,CellEnter事件是切换ActiveCell时,某个Cell变成当前Cell了,会发这个事件。这个和你的理解不太一样。

我建议你先详细描述一下目前是需要什么功能,是需要在什么时候触发。然后我帮你确认解决办法
回复 使用道具 举报
zgblxy
注册会员   /  发表于:2019-6-20 17:25:00
6#
好的,我是想在点击单元格输入完之后,点击回车,触发之后的事件。
回复 使用道具 举报
zgblxy
注册会员   /  发表于:2019-6-20 17:26:03
7#
我理解的可能不是很对,我理解的是cellenter事件就是点击回车事件呢。
回复 使用道具 举报
zgblxy
注册会员   /  发表于:2019-6-20 17:29:10
8#
我就是想我把焦点放到这个单元格上,输入完成,点击回车,确定完。然后就会有后面的操作,计算出数来。
现在我的情况是输入完,点击回车没有反应,但是失去焦点后才会有下边的操作。
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-6-20 18:24:19
9#
好的,明天我会验证一下你这边需要的功能如何实现,然后给你答复
回复 使用道具 举报
zgblxy
注册会员   /  发表于:2019-6-21 09:02:16
10#
好的,谢谢您
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部