シート初期状態でコピー、切り取り、貼り付け処理は
次のように動作した。(間違ってたらすいません。)
(1)行、列のヘッダラベルのコピー、切り取り、貼り付けができる。
(2)列を選択してCheckBoxCellType、ComboBoxCellType等のコピー、切り取りができる。
ただし、セルを選択したとき場合にはできない。
(3)書式(色)のコピー、切り取り、貼り付けができる。
(4)ReadOnlyに設定したTextCellTypeに貼り付けができる。
つまり、初期状態では、ユーザーのコピー、切り取り、貼り付け操作で
自由にシートの外観を変更できてしまう。
なので、スプレッドを初期化するときにいつも画面仕様にあわせ
次のようなコードを書くようになる。
Imports FarPoint.Win.Spread
ClipboardOptionsを指定して、ヘッダのコピペ、カトペを制御
FpSpread1.ClipboardOptions = ClipboardOptions.NoHeaders
'値のみコピペ、カトペできるようにキーマップを設定
Dim im As New InputMap
With FpSpread1
' カット[Ctrl]+[X]の入力マップを変更します
im = .GetInputMap(InputMapMode.WhenFocused)
im.Put(New Keystroke(Keys.X, Keys.Control), SpreadActions.ClipboardCutDataOnly)
' ペースト[Ctrl]+[V]の入力マップを変更します
im = .GetInputMap(InputMapMode.WhenFocused)
im.Put(New Keystroke(Keys.V, Keys.Control), SpreadActions.ClipboardPasteValues)
' カット[Shift]+[Delete]の入力マップを変更します
im = .GetInputMap(InputMapMode.WhenFocused)
im.Put(New Keystroke(Keys.Delete, Keys.Shift), SpreadActions.ClipboardCutDataOnly)
' ペースト[Shift]+[Insert]の入力マップを変更します
im = .GetInputMap(InputMapMode.WhenFocused)
im.Put(New Keystroke(Keys.Insert, Keys.Shift), SpreadActions.ClipboardPasteValues)
End With
コピーペストを無効にするようにキーマップを設定
Dim im As New InputMap
With FpSpread1
' カット[Ctrl]+[X]の入力マップを変更します
im = .GetInputMap(InputMapMode.WhenFocused)
im.Put(New Keystroke(Keys.X, Keys.Control), SpreadActions.None)
' ペースト[Ctrl]+[V]の入力マップを変更します
im = .GetInputMap(InputMapMode.WhenFocused)
im.Put(New Keystroke(Keys.V, Keys.Control), SpreadActions.None)
' カット[Shift]+[Delete]の入力マップを変更します
im = .GetInputMap(InputMapMode.WhenFocused)
im.Put(New Keystroke(Keys.Delete, Keys.Shift), SpreadActions.None)
' ペースト[Shift]+[Insert]の入力マップを変更します
im = .GetInputMap(InputMapMode.WhenFocused)
im.Put(New Keystroke(Keys.Insert, Keys.Shift), SpreadActions.None)
End With
今回は、EXCELなどから貼り付けした時の動作や
バインドしている時の動作は割愛します。
また、詳細な仕様に対応するには、
ClipboardPastingイベントで制御する必要があります。