作成日: 2018/06/25 最終更新日: 2018/06/25
文書種別
使用方法
詳細
[Enter]キーに割り当てられているデフォルトの入力マップをMoveToNextColumnWrapすることで、[Enter]キーで隣のセルに移動します。GcComboBox型セルを使用することで隣のセルに移動することができます。なおドロップダウンリストが表示されている状態では、[Enter]キーはドロップダウンリストを閉じる動作に使用されるため、編集コントロール(GcComboBoxEditingControl)のKeyイベントで明示的に隣のセルに移動させる必要があります。
◎サンプルコード(VB)
◎サンプルコード(C#)
◎サンプルコード(VB)
Dim WithEvents Combo As New GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxEditingControl()
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' GcComboBoxCellType型セルを第2列に設定
Dim cbCell As New GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType()
cbCell.DropDownStyle = ComboBoxStyle.DropDownList
cbCell.Items.AddRange({"123", "456", "789", "abc", "def"})
cbCell.ListHeaderPane.Visible = False
cbCell.UseCompatibleDrawing = True
FpSpread1.ActiveSheet.Columns(1).CellType = cbCell
' 入力マップの設定([Enter]キーで隣のセルに移動)
Dim im As FarPoint.Win.Spread.InputMap
im = FpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap)
im = FpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap)
End Sub
Private Sub FpSpread1_EditModeOn(sender As Object, e As EventArgs) Handles FpSpread1.EditModeOn
' セル型がコンボボックス型の場合は、EditingControlをComboにマッピング
Dim iRow As Integer = FpSpread1.ActiveSheet.ActiveRowIndex
Dim iCol As Integer = FpSpread1.ActiveSheet.ActiveColumnIndex
If TypeOf (FpSpread1.ActiveSheet.GetCellType(iRow, iCol)) Is GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType Then
Combo = CType(FpSpread1.EditingControl, GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxEditingControl)
End If
End Sub
Private Sub Combo_KeyUp(sender As Object, e As KeyEventArgs) Handles Combo.KeyUp
If e.KeyCode = Keys.Return Then
FpSpread1.GetActionMap().Get(FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap).PerformAction(FpSpread1.GetRootWorkbook())
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' GcComboBoxCellType型セルを第2列に設定
Dim cbCell As New GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType()
cbCell.DropDownStyle = ComboBoxStyle.DropDownList
cbCell.Items.AddRange({"123", "456", "789", "abc", "def"})
cbCell.ListHeaderPane.Visible = False
cbCell.UseCompatibleDrawing = True
FpSpread1.ActiveSheet.Columns(1).CellType = cbCell
' 入力マップの設定([Enter]キーで隣のセルに移動)
Dim im As FarPoint.Win.Spread.InputMap
im = FpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap)
im = FpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap)
End Sub
Private Sub FpSpread1_EditModeOn(sender As Object, e As EventArgs) Handles FpSpread1.EditModeOn
' セル型がコンボボックス型の場合は、EditingControlをComboにマッピング
Dim iRow As Integer = FpSpread1.ActiveSheet.ActiveRowIndex
Dim iCol As Integer = FpSpread1.ActiveSheet.ActiveColumnIndex
If TypeOf (FpSpread1.ActiveSheet.GetCellType(iRow, iCol)) Is GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType Then
Combo = CType(FpSpread1.EditingControl, GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxEditingControl)
End If
End Sub
Private Sub Combo_KeyUp(sender As Object, e As KeyEventArgs) Handles Combo.KeyUp
If e.KeyCode = Keys.Return Then
FpSpread1.GetActionMap().Get(FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap).PerformAction(FpSpread1.GetRootWorkbook())
End If
End Sub
◎サンプルコード(C#)
private GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxEditingControl Combo;
private void Form1_Load(object sender, EventArgs e)
{
// GcComboBoxCellType型セルを第2列に設定
GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType cbCell = new GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType();
cbCell.DropDownStyle = ComboBoxStyle.DropDownList;
cbCell.Items.AddRange(new string[] { "123", "456", "789", "abc", "def" });
cbCell.ListHeaderPane.Visible = false;
cbCell.UseCompatibleDrawing = true;
fpSpread1.ActiveSheet.Columns[1].CellType = cbCell;
// 入力マップの設定([Enter]キーで隣のセルに移動)
FarPoint.Win.Spread.InputMap im = default(FarPoint.Win.Spread.InputMap);
im = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused);
im.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap);
im = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused);
im.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap);
}
private void FpSpread1_EditModeOn(object sender, EventArgs e)
{
// セル型がGcComboBoxCellType型セルの場合は、EditingControlをComboにマッピング
int iRow = fpSpread1.ActiveSheet.ActiveRowIndex;
int iCol = fpSpread1.ActiveSheet.ActiveColumnIndex;
if ((fpSpread1.ActiveSheet.GetCellType(iRow, iCol)) is GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType)
{
Combo = (GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxEditingControl)fpSpread1.EditingControl;
Combo.KeyUp -= Combo_KeyUp;
Combo.KeyUp += Combo_KeyUp;
}
}
private void Combo_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return)
{
fpSpread1.GetActionMap().Get(FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap).PerformAction(fpSpread1.GetRootWorkbook());
}
}
private void Form1_Load(object sender, EventArgs e)
{
// GcComboBoxCellType型セルを第2列に設定
GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType cbCell = new GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType();
cbCell.DropDownStyle = ComboBoxStyle.DropDownList;
cbCell.Items.AddRange(new string[] { "123", "456", "789", "abc", "def" });
cbCell.ListHeaderPane.Visible = false;
cbCell.UseCompatibleDrawing = true;
fpSpread1.ActiveSheet.Columns[1].CellType = cbCell;
// 入力マップの設定([Enter]キーで隣のセルに移動)
FarPoint.Win.Spread.InputMap im = default(FarPoint.Win.Spread.InputMap);
im = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused);
im.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap);
im = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused);
im.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap);
}
private void FpSpread1_EditModeOn(object sender, EventArgs e)
{
// セル型がGcComboBoxCellType型セルの場合は、EditingControlをComboにマッピング
int iRow = fpSpread1.ActiveSheet.ActiveRowIndex;
int iCol = fpSpread1.ActiveSheet.ActiveColumnIndex;
if ((fpSpread1.ActiveSheet.GetCellType(iRow, iCol)) is GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType)
{
Combo = (GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxEditingControl)fpSpread1.EditingControl;
Combo.KeyUp -= Combo_KeyUp;
Combo.KeyUp += Combo_KeyUp;
}
}
private void Combo_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return)
{
fpSpread1.GetActionMap().Get(FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap).PerformAction(fpSpread1.GetRootWorkbook());
}
}
旧文書番号
82981