作成日: 2018/05/31 最終更新日: 2018/05/31
文書種別
使用方法
詳細
行選択モード(OperationMode.RowMode)では、デフォルトで[Ctrl + C]キーおよび[Ctrl + V]キーに対するコピーおよび貼り付け処理を行う入力マップが設定されていません。行選択モードのときにアクティブセルの値をコピーする場合は、セルを編集状態にしてから文字列を選択してコピーする方法か、独自のアクションをCtrl+Cキーに設定する方法が考えられます。
◎サンプルコード(VB)
カスタムアクション
◎サンプルコード(C#)
カスタムアクション
◎サンプルコード(VB)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FpSpread1.ActiveSheet.OperationMode = FarPoint.Win.Spread.OperationMode.RowMode
' アクションをマッピングします
Dim am As FarPoint.Win.Spread.ActionMap = FpSpread1.GetActionMap()
am.Put("CustomCopyAction", New CustomCopyAction())
' 作成したサブクラスをマッピングします
Dim im As FarPoint.Win.Spread.InputMap = FpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.C, Keys.Control), "CustomCopyAction")
End Sub
FpSpread1.ActiveSheet.OperationMode = FarPoint.Win.Spread.OperationMode.RowMode
' アクションをマッピングします
Dim am As FarPoint.Win.Spread.ActionMap = FpSpread1.GetActionMap()
am.Put("CustomCopyAction", New CustomCopyAction())
' 作成したサブクラスをマッピングします
Dim im As FarPoint.Win.Spread.InputMap = FpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.C, Keys.Control), "CustomCopyAction")
End Sub
カスタムアクション
Public Class CustomCopyAction
Inherits FarPoint.Win.Spread.Action
Public Overrides Sub PerformAction(ByVal sender As Object)
If TypeOf sender Is FarPoint.Win.Spread.SpreadView Then
' SPREADとSheetの取得
Dim spread As FarPoint.Win.Spread.SpreadView = CType(sender, FarPoint.Win.Spread.SpreadView)
Dim sheet As FarPoint.Win.Spread.SheetView = spread.Sheets(spread.ActiveSheetIndex)
' クリップボードへ設定
Dim data As String = String.Concat(sheet.ActiveCell.Value)
Clipboard.SetText(data)
End If
End Sub
End Class
Inherits FarPoint.Win.Spread.Action
Public Overrides Sub PerformAction(ByVal sender As Object)
If TypeOf sender Is FarPoint.Win.Spread.SpreadView Then
' SPREADとSheetの取得
Dim spread As FarPoint.Win.Spread.SpreadView = CType(sender, FarPoint.Win.Spread.SpreadView)
Dim sheet As FarPoint.Win.Spread.SheetView = spread.Sheets(spread.ActiveSheetIndex)
' クリップボードへ設定
Dim data As String = String.Concat(sheet.ActiveCell.Value)
Clipboard.SetText(data)
End If
End Sub
End Class
◎サンプルコード(C#)
private void Form1_Load(object sender, EventArgs e)
{
fpSpread1.ActiveSheet.OperationMode = FarPoint.Win.Spread.OperationMode.RowMode;
// アクションをマッピングします
FarPoint.Win.Spread.ActionMap am = fpSpread1.GetActionMap();
am.Put("CustomCopyAction", new CustomCopyAction());
// 作成したサブクラスをマッピングします
FarPoint.Win.Spread.InputMap im = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused);
im.Put(new FarPoint.Win.Spread.Keystroke(Keys.C, Keys.Control), "CustomCopyAction");
}
{
fpSpread1.ActiveSheet.OperationMode = FarPoint.Win.Spread.OperationMode.RowMode;
// アクションをマッピングします
FarPoint.Win.Spread.ActionMap am = fpSpread1.GetActionMap();
am.Put("CustomCopyAction", new CustomCopyAction());
// 作成したサブクラスをマッピングします
FarPoint.Win.Spread.InputMap im = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused);
im.Put(new FarPoint.Win.Spread.Keystroke(Keys.C, Keys.Control), "CustomCopyAction");
}
カスタムアクション
public class CustomCopyAction : FarPoint.Win.Spread.Action
{
public override void PerformAction(object sender)
{
if (sender is FarPoint.Win.Spread.SpreadView)
{
// SPREADとSheetの取得
FarPoint.Win.Spread.SpreadView spread = (FarPoint.Win.Spread.SpreadView)sender;
FarPoint.Win.Spread.SheetView sheet = spread.Sheets[spread.ActiveSheetIndex];
// クリップボードへ設定
string data = String.Concat(sheet.ActiveCell.Value);
Clipboard.SetText(data);
}
}
}
{
public override void PerformAction(object sender)
{
if (sender is FarPoint.Win.Spread.SpreadView)
{
// SPREADとSheetの取得
FarPoint.Win.Spread.SpreadView spread = (FarPoint.Win.Spread.SpreadView)sender;
FarPoint.Win.Spread.SheetView sheet = spread.Sheets[spread.ActiveSheetIndex];
// クリップボードへ設定
string data = String.Concat(sheet.ActiveCell.Value);
Clipboard.SetText(data);
}
}
}
旧文書番号
82803