控件中国网现已改版,您看到的是老版本网站的镜像,系统正在为您跳转到新网站首页,请稍候.......
中国最专业的商业控件资讯网产品咨询电话:023-67870900 023-67871946
产品咨询EMAIL:SALES@COMPONENTCN.COM

Spread for Windows Forms中光标移动的问题

作者:葡萄城 出处:葡萄城 2010年08月10日 阅读:

问:

我想要实现的是:如果在单元格中输入的是数字,光标离开时,弹出MSG,并把光标返回原单元格。
问题是:我做了以下处理以后,光标会先返回原单元格,然后又移动到下一个单元格。有一个闪动的过程。
Public Class Form1

    Public Sub SetEnterKey(ByVal FpSpread As FarPoint.Win.Spread.FpSpread)
        Dim im As New FarPoint.Win.Spread.InputMap()

        ' 非編集セルでの[Enter]キーを「次列へ移動」とします
        im = FpSpread.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused)
        im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap)
        im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.Shift), FarPoint.Win.Spread.SpreadActions.MoveToPreviousColumnWrap)

        ' 編集中セルでの[Enter]キーを「次列へ移動」とします
        im = FpSpread.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused)
        im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap)
        im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.Shift), FarPoint.Win.Spread.SpreadActions.MoveToPreviousColumnWrap)

        '' SPREADにフォーカスを移動させます
        'FpSpread.Focus()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SetEnterKey(Me.FpSpread1)
    End Sub

    Private Sub FpSpread1_Change(ByVal sender As System.Object, ByVal e As FarPoint.Win.Spread.ChangeEventArgs) Handles FpSpread1.Change

        Dim intR As Integer = Me.FpSpread1.ActiveSheet.ActiveRowIndex

        If IsNumeric(FpSpread1.ActiveSheet.Cells(intR, 0).Value) Then
            MsgBox("IsNumeric,Focus Back!")
            Me.FpSpread1.ActiveSheet.SetActiveCell(intR, 0)
        End If

    End Sub

End Class

版本信息:
SPREAD for .NET 3.0J Windows Forms Edition リリースノート
Version 3.0.2010.2005

答:

不是办法的办法

 
本身没有什么好的办法。试一下下面这个吧,这个可以先解决你的可题。


Public Class Form1
    Dim intR As Integer = -1
    Dim intC As Integer = -1

    Public Sub SetEnterKey(ByVal FpSpread As FarPoint.Win.Spread.FpSpread)
        Dim im As New FarPoint.Win.Spread.InputMap()

        ' 非編集セルでの[Enter]キーを「次列へ移動」とします
        im = FpSpread.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused)
        im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap)
        im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.Shift), FarPoint.Win.Spread.SpreadActions.MoveToPreviousColumnWrap)

        ' 編集中セルでの[Enter]キーを「次列へ移動」とします
        im = FpSpread.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused)
        im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap)
        im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.Shift), FarPoint.Win.Spread.SpreadActions.MoveToPreviousColumnWrap)

        '' SPREADにフォーカスを移動させます
        'FpSpread.Focus()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SetEnterKey(Me.FpSpread1)
    End Sub

    Private Sub FpSpread1_Change(ByVal sender As System.Object, ByVal e As FarPoint.Win.Spread.ChangeEventArgs) Handles FpSpread1.Change

        'Dim intR As Integer = Me.FpSpread1.ActiveSheet.ActiveRowIndex
        intR = Me.FpSpread1.ActiveSheet.ActiveRowIndex
        intC = Me.FpSpread1.ActiveSheet.ActiveColumnIndex

        If IsNumeric(FpSpread1.ActiveSheet.Cells(intR, intC).Value) Then
            MsgBox("IsNumeric,Focus Back!")
            'Me.FpSpread1.ActiveSheet.SetActiveCell(intR, 0)
        Else
            intR = -1
            intC = -1
        End If

    End Sub

    Private Sub FpSpread1_EnterCell(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.EnterCellEventArgs) Handles FpSpread1.EnterCell
        If intR <> -1 Then Me.FpSpread1.ActiveSheet.SetActiveCell(intR, intC)
    End Sub
End Class

Spread for Windows Forms产品介绍和下载地址:http://www.componentcn.com/?thread-6547-1.html

热推产品

  • ActiveReport... 强大的.NET报表设计、浏览、打印、转换控件,可以同时用于WindowsForms谀坔攀戀Forms平台下......
  • AnyChart AnyChart使你可以创建出绚丽的交互式的Flash和HTML5的图表和仪表控件。可以用于仪表盘的创......
首页 | 新闻中心 | 产品中心 | 技术文档 | 友情连接 | 关于磐岩 | 技术支持中心 | 联系我们 | 帮助中心 Copyright-2006 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 电话:023 - 67870900 传真:023 - 67870270 产品咨询:sales@componentcn.com 渝ICP备12000264号 法律顾问:元炳律师事务所 重庆市江北区塔坪36号维丰创意绿苑A座28-5 邮编:400020
在线客服
在线客服系统
在线客服
在线客服系统