作成日: 2018/06/21 最終更新日: 2018/06/21
文書種別
使用方法
詳細
セルのLockedプロパティをTrueにすることで、セルの編集などを含めセルのドラッグ&ドロップも禁止することができます。
セルの編集を許可した上で、特定のセルのドラッグ&ドロップだけを禁止するには、DragDropBlockイベントでセルのインデックスを判定しe.Cancel = Trueにします。なお、セル単位でドラッグ&ドロップの操作そのもの(マウスカーソルの変更など)を禁止する方法は用意されていません。
◎サンプルコード(VB)
◎サンプルコード(C#)
セルの編集を許可した上で、特定のセルのドラッグ&ドロップだけを禁止するには、DragDropBlockイベントでセルのインデックスを判定しe.Cancel = Trueにします。なお、セル単位でドラッグ&ドロップの操作そのもの(マウスカーソルの変更など)を禁止する方法は用意されていません。
◎サンプルコード(VB)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FpSpread1.AllowDragDrop = True
FpSpread1.ActiveSheet.SetValue(0, 0, "abc")
End Sub
Private Sub FpSpread1_DragDropBlock(ByVal sender As System.Object, ByVal e As FarPoint.Win.Spread.DragDropBlockEventArgs) Handles FpSpread1.DragDropBlock
' セルA1の移動を禁止
If e.ColumnBegin = 0 And e.RowBegin = 0 Then
e.Cancel = True
End If
'' 1列目のセルの移動を禁止
'If e.ColumnBegin = 0 Then ' e.Cancel = True
'End If
'' 1行目のセルの移動を禁止
'If e.RowBegin = 0 Then
' e.Cancel = True
'End If
End Sub
FpSpread1.AllowDragDrop = True
FpSpread1.ActiveSheet.SetValue(0, 0, "abc")
End Sub
Private Sub FpSpread1_DragDropBlock(ByVal sender As System.Object, ByVal e As FarPoint.Win.Spread.DragDropBlockEventArgs) Handles FpSpread1.DragDropBlock
' セルA1の移動を禁止
If e.ColumnBegin = 0 And e.RowBegin = 0 Then
e.Cancel = True
End If
'' 1列目のセルの移動を禁止
'If e.ColumnBegin = 0 Then ' e.Cancel = True
'End If
'' 1行目のセルの移動を禁止
'If e.RowBegin = 0 Then
' e.Cancel = True
'End If
End Sub
◎サンプルコード(C#)
private void Form1_Load(object sender, EventArgs e)
{
fpSpread1.AllowDragDrop = true;
fpSpread1.ActiveSheet.SetValue(0, 0, "abc");
}
private void fpSpread1_DragDropBlock(object sender, FarPoint.Win.Spread.DragDropBlockEventArgs e)
{
// セルA1の移動を禁止
if (e.ColumnBegin == 0 && e.RowBegin == 0)
{
e.Cancel = true;
}
//// 1列目のセルの移動を禁止
//if (e.ColumnBegin == 0) //{
// e.Cancel = true;
//}
//// 1行目のセルの移動を禁止
//if (e.RowBegin == 0)
//{
// e.Cancel = true;
//}
}
{
fpSpread1.AllowDragDrop = true;
fpSpread1.ActiveSheet.SetValue(0, 0, "abc");
}
private void fpSpread1_DragDropBlock(object sender, FarPoint.Win.Spread.DragDropBlockEventArgs e)
{
// セルA1の移動を禁止
if (e.ColumnBegin == 0 && e.RowBegin == 0)
{
e.Cancel = true;
}
//// 1列目のセルの移動を禁止
//if (e.ColumnBegin == 0) //{
// e.Cancel = true;
//}
//// 1行目のセルの移動を禁止
//if (e.RowBegin == 0)
//{
// e.Cancel = true;
//}
}
旧文書番号
82948