找回密码
 立即注册

QQ登录

只需一步,快速开始

miyaminn

论坛元老

48

主题

121

帖子

2万

积分

论坛元老

积分
22182

活字格认证

miyaminn
论坛元老   /  发表于:2014-8-6 13:27  /   查看:4720  /  回复:1
Spread中有很多列,每个列的类型不同,文字列按F3,F4会进入编辑模式,
现在想禁掉加了如下代码:
Dim whenAncestorOfFocused As InputMap = _
        FpSpread1.GetInputMap(InputMapMode.WhenAncestorOfFocused)
Dim whenFocused As InputMap = _
        FpSpread1.GetInputMap(InputMapMode.WhenFocused)

whenAncestorOfFocused.Put(New Keystroke(Keys.F3, Keys.None), SpreadActions.None)
whenFocused.Put(New Keystroke(Keys.F3, Keys.None), SpreadActions.None)
whenAncestorOfFocused.Put(New Keystroke(Keys.F4, Keys.None), SpreadActions.None)
whenFocused.Put(New Keystroke(Keys.F4, Keys.None), SpreadActions.None)

可是这样就把日期列的快捷键F3,F4也给屏蔽了,
这个要怎么做呢?屏蔽到非日期列的快捷键。

1 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2014-8-6 17:33:00
沙发
回复 1楼miyaminn的帖子

可以通过自定义快捷键动作实现:

  1. Public Class Form1

  2.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  3.         Dim dt As New FarPoint.Win.Spread.CellType.DateTimeCellType
  4.         FpSpread1.ActiveSheet.Columns(0).CellType = dt

  5.         Dim txt As New FarPoint.Win.Spread.CellType.TextCellType()
  6.         txt.CharacterCasing = CharacterCasing.Upper
  7.         txt.CharacterSet = FarPoint.Win.Spread.CellType.CharacterSet.Ascii
  8.         txt.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show
  9.         txt.MaxLength = 40
  10.         txt.Multiline = True
  11.         txt.PasswordChar = "*"
  12.         txt.ScrollBars = ScrollBars.Vertical
  13.         txt.Static = True
  14.         FpSpread1.Sheets(0).Columns(1).CellType = txt
  15.         FpSpread1.Sheets(0).Cells(0, 1).Text = "This is a text cell.  It can provide a wide range of" & _
  16.         " functionality for handling a large amount of data that a user might want to include" & _
  17.         " in a single cell."

  18.         Dim im As New InputMap
  19.         im = FpSpread1.GetInputMap(InputMapMode.WhenFocused)
  20.         Dim am As ActionMap
  21.         am = FpSpread1.GetActionMap()

  22.         im.Put(New Keystroke(Keys.F3, Keys.None), "NewControlHomeAction")
  23.         am.Put("NewControlHomeAction", New NewControlHomeAction())
  24.         im.Put(New Keystroke(Keys.F4, Keys.None), "NewControlHomeAction")
  25.         am.Put("NewControlHomeAction", New NewControlHomeAction())

  26.     End Sub
  27. End Class

  28. Public Class NewControlHomeAction
  29.     Inherits FarPoint.Win.Spread.Action
  30.     Public Overrides Sub PerformAction(source As Object)
  31.         If TypeOf source Is SpreadView Then
  32.             Dim spread As SpreadView = DirectCast(source, SpreadView)
  33.             If TypeOf spread.Sheets(spread.ActiveSheetIndex).ActiveColumn.CellType Is FarPoint.Win.Spread.CellType.DateTimeCellType Then
  34.                 spread.EditMode = True
  35.             Else
  36.                 spread.EditMode = False
  37.             End If
  38.         End If
  39.     End Sub
  40. End Class
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部