找回密码
 立即注册

QQ登录

只需一步,快速开始

wangmj

论坛元老

14

主题

44

帖子

1万

积分

论坛元老

积分
10158

活字格认证

wangmj
论坛元老   /  发表于:2013-9-16 10:54  /   查看:5341  /  回复:3
我的spread中使用了MultiColumnComboBoxCell,想要在MultiColumnComboBoxCell中捕捉到esc按下的事件,然后进行其他处理,相同的代码在textboxcell中好用,在MultiColumnComboBoxCell中就不行了,拜托帮忙看看是什么原因造成的。

'========================================================
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.sprData.EditModePermanent = True
Dim im As New FarPoint.Win.Spread.InputMap
im = Me.sprData.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.None)
end Sub

Private Sub sprData_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles sprData.KeyDown
Try
Select Case e.KeyCode
Case Windows.Forms.Keys.Escape
Me.MsubESCKeyEvent()
Case Windows.Forms.Keys.F1
Me.MsubF1KeyEvent()
End Select

Catch ex As Exception
throw ex
End Try
End Sub

Private Sub sprData_EditModeOn(ByVal sender As Object, ByVal e As System.EventArgs) Handles sprData.EditModeOn
Try
Dim KeyDownHandler As Windows.Forms.KeyEventHandler = AddressOf Me.sprData_KeyDown
'AddHandler Me.sprData.EditingControl.KeyDown, KeyDownHandler
Catch ex As Exception
throw ex
End Try
End Sub

Private Sub sprData_EditModeOff(ByVal sender As Object, ByVal e As System.EventArgs) Handles sprData.EditModeOff
Try
Dim KeyDownHandler As Windows.Forms.KeyEventHandler = AddressOf Me.sprData_KeyDown
RemoveHandler Me.sprData.EditingControl.KeyDown, KeyDownHandler
Catch ex As Exception
throw ex
End Try
End Sub
'==================================================

3 个回复

倒序浏览
山水
初级会员   /  发表于:2013-9-16 16:53:00
沙发
您好,
     Escape键是系统键, 在Spread的KeyDown事件中是不能截获的。要截获之,需重载Win Form的ProcessCmdKey()方法。
     您可改变您的代码如下来解决您的问题:
     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.sprData.EditModePermanent = True
        Dim im As New FarPoint.Win.Spread.InputMap
        im = Me.sprData.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused)
        im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.None)
    End Sub

    Protected Overrides Function ProcessCmdKey(ByRef msg As Message, keyData As Keys) As Boolean
        Try
            Select Case keyData
                Case Windows.Forms.Keys.Escape
                    Me.MsubESCKeyEvent()
                Case Windows.Forms.Keys.F1
                    Me.MsubF1KeyEvent()
            End Select

        Catch ex As Exception
            Throw ex
        End Try
        Return MyBase.ProcessCmdKey(msg, keyData)
    End Function


    Private Sub MsubESCKeyEvent()

    End Sub

    Private Sub MsubF1KeyEvent()

    End Sub
回复 使用道具 举报
wangmj
论坛元老   /  发表于:2013-11-27 21:29:00
板凳
多谢多谢。
真是太有用了。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-11-28 09:10:00
地板
回复 3楼wangmj的帖子


不客气,有问题欢迎开新帖提问。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部