找回密码
 立即注册

QQ登录

只需一步,快速开始

dorothe

新手上路

1

主题

3

帖子

33

积分

新手上路

积分
33
  • 30

    金币

  • 主题

  • 帖子

最新发帖
dorothe
新手上路   /  发表于:2013-11-29 16:58  /   查看:6718  /  回复:6
我用的是spread7
在spread7有个单元格使用的是GcDateTimeEditingControl。
现在其他的function key都能捕捉到,只有F5捕捉不到。总是执行它默认的操作(把单元格的值设置成当前系统日期)
我的使用方法如下:
'========================================================
Private Sub InitSpread()
With Me.sprList
                .EditMode = True
                .EditModePermanent = True                Dim inputmap1 As New FarPoint.Win.Spread.InputMap()
                Dim inputmap2 As New FarPoint.Win.Spread.InputMap()
                inputmap1 = .GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused)
                inputmap1.Put(New FarPoint.Win.Spread.Keystroke(Keys.Escape, Keys.None), FarPoint.Win.Spread.SpreadActions.None)
                inputmap1.Put(New FarPoint.Win.Spread.Keystroke(Keys.F1, Keys.None), FarPoint.Win.Spread.SpreadActions.None)
                inputmap1.Put(New FarPoint.Win.Spread.Keystroke(Keys.F2, Keys.None), FarPoint.Win.Spread.SpreadActions.None)
                inputmap1.Put(New FarPoint.Win.Spread.Keystroke(Keys.F3, Keys.None), FarPoint.Win.Spread.SpreadActions.None)
                inputmap1.Put(New FarPoint.Win.Spread.Keystroke(Keys.F4, Keys.None), FarPoint.Win.Spread.SpreadActions.None)
                inputmap1.Put(New FarPoint.Win.Spread.Keystroke(Keys.F5, Keys.None), FarPoint.Win.Spread.SpreadActions.None)
                inputmap1.Put(New FarPoint.Win.Spread.Keystroke(Keys.F6, Keys.None), FarPoint.Win.Spread.SpreadActions.None)
                inputmap1.Put(New FarPoint.Win.Spread.Keystroke(Keys.F7, Keys.None), FarPoint.Win.Spread.SpreadActions.None)
                inputmap1.Put(New FarPoint.Win.Spread.Keystroke(Keys.F8, Keys.None), FarPoint.Win.Spread.SpreadActions.None)
                inputmap1.Put(New FarPoint.Win.Spread.Keystroke(Keys.F9, Keys.None), FarPoint.Win.Spread.SpreadActions.None)
                inputmap1.Put(New FarPoint.Win.Spread.Keystroke(Keys.F10, Keys.None), FarPoint.Win.Spread.SpreadActions.None)
                inputmap1.Put(New FarPoint.Win.Spread.Keystroke(Keys.F11, Keys.None), FarPoint.Win.Spread.SpreadActions.None)
                inputmap1.Put(New FarPoint.Win.Spread.Keystroke(Keys.F12, Keys.None), FarPoint.Win.Spread.SpreadActions.None)
                inputmap2 = .GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused)
                inputmap2.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.None)
                .Enabled = False
            End With
End Sub
'========================================================
    Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
        Try
            Select Case keyData
                Case Windows.Forms.Keys.Escape
                    Me.MsubESCKeyEvent()
                Case Windows.Forms.Keys.F1
                    Me.MsubF1KeyEvent()
                Case Windows.Forms.Keys.F5
                    Me.MsubF5KeyEvent()
            End Select
        Catch ex As Exception
            Throw ex
        End Try
    End Function

6 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2013-11-29 18:07:00
沙发
回复 1楼dorothe的帖子

如果你指的是 detect Spread F5 快捷键,那么可以通过 fpSpread1_PreviewKeyDown 获取。

GcDateTimeEditingControl 对 F5 做了内部处理操作,我暂时还没有找办法获取。正在调查中。
回复 使用道具 举报
dorothe
新手上路   /  发表于:2013-11-30 14:49:00
板凳
回复 2楼iceman的帖子

多谢版主回复,
我想屏蔽GcDateTimeEditingControl自己的F5事件,这个动作在spread的keydown事件中捕捉不到。
你提到的previewkeydown事件,我没用过,现在试试去。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-12-2 11:47:00
地板
回复 3楼dorothe的帖子

dorothe 你好,
这个问题我已经发送给产品组调查,有结果我会反馈给你。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-12-3 09:51:00
5#
回复 3楼dorothe的帖子

首先需要移除 F5 的默认行为,具体做法参见代码:

  1.         private void Form1_Load(object sender, EventArgs e)
  2.         {
  3.             GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType datecell = new GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType();
  4.             datecell.MaxDate = new System.DateTime(9999, 12, 31);
  5.             datecell.MinDate = DateTime.Now;
  6.             datecell.MaxMinBehavior = GrapeCity.Win.Spread.InputMan.CellType.MaxMinBehavior.Clear;
  7.             datecell.ShortcutKeys.Remove(Keys.F5);
  8.             fpSpread1.Sheets[0].Cells[0, 0].CellType = datecell;

  9.             fpSpread1.EditModeOn += new EventHandler(fpSpread1_EditModeOn);
  10.         }

  11.         void fpSpread1_EditModeOn(object sender, EventArgs e)
  12.         {
  13.             GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeEditingControl gcec = this.fpSpread1.EditingControl as GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeEditingControl;

  14.             if (gcec != null)
  15.             {
  16.                 gcec.KeyDown += new KeyEventHandler(gcec_KeyDown);
  17.                 gcec.PreviewKeyDown += new PreviewKeyDownEventHandler(gcec_PreviewKeyDown);
  18.             }
  19.         }

  20.         void gcec_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
  21.         {
  22.             throw new NotImplementedException();
  23.         }
复制代码
回复 使用道具 举报
dorothe
新手上路   /  发表于:2013-12-13 15:25:00
6#
回复 5楼iceman的帖子

多谢帮助,我去试试
回复 使用道具 举报
roger.wang
社区贡献组   /  发表于:2013-12-13 16:51:00
7#
回复 6楼dorothe的帖子

请问,可以了吗?
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部