行モードのとき、最右端カラムのENTER押下で次行に移動したい
対象製品
El Tabelle Sheet 4.0J
詳細
El Tabelle Sheet 4.0Jでは、選択範囲内でのセルの移動は、Excel で複数セルを選択してTabキーで移動したときと同様な動作となります。行モード(ViewMode.Row)の場合、行が選択されている状態となりその行内でのセルの移動となります。このため、右カラムENTER押下で(選択されている)行の先頭にセルが移動します。
行モードで、最右端カラムのENTER押下で次行に移動したい場合は、KeyDownイベントを実装して移動します。サンプルソースを下記に示します。
[Visual Basic]
[C#]
行モードで、最右端カラムのENTER押下で次行に移動したい場合は、KeyDownイベントを実装して移動します。サンプルソースを下記に示します。
[Visual Basic]
Private Sub Sheet1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Sheet1.KeyDown
If e.KeyCode = Keys.Enter Then
If e.Shift = False Then
'最右カラムでかつ、一番下の行ではない場合 → 改行する。
If (Sheet1.ActivePosition.Row <> (Sheet1.MaxRows - 1)) And _
(Sheet1.ActivePosition.Column = (Sheet1.MaxColumns - 1)) Then
Sheet1.ActivePosition = _
New GrapeCity.Win.ElTabelle.Position(0, Sheet1.ActivePosition.Row + 1)
e.Handled = True
'最右カラム以外のケース。→ 右セルに移動する。
ElseIf Sheet1.ActivePosition.Column <> Sheet1.MaxColumns - 1 Then
Sheet1.ActivePosition = _
New GrapeCity.Win.ElTabelle.Position(Sheet1.ActivePosition.Column + 1, Sheet1.ActivePosition.Row)
e.Handled = True
End If
End If
End If
End Sub
If e.KeyCode = Keys.Enter Then
If e.Shift = False Then
'最右カラムでかつ、一番下の行ではない場合 → 改行する。
If (Sheet1.ActivePosition.Row <> (Sheet1.MaxRows - 1)) And _
(Sheet1.ActivePosition.Column = (Sheet1.MaxColumns - 1)) Then
Sheet1.ActivePosition = _
New GrapeCity.Win.ElTabelle.Position(0, Sheet1.ActivePosition.Row + 1)
e.Handled = True
'最右カラム以外のケース。→ 右セルに移動する。
ElseIf Sheet1.ActivePosition.Column <> Sheet1.MaxColumns - 1 Then
Sheet1.ActivePosition = _
New GrapeCity.Win.ElTabelle.Position(Sheet1.ActivePosition.Column + 1, Sheet1.ActivePosition.Row)
e.Handled = True
End If
End If
End If
End Sub
[C#]
private void sheet1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (e.Shift == false){
// 最右カラムでかつ、一番下の行ではない場合は改行する。
if ((sheet1.ActivePosition.Row != sheet1.MaxRows - 1) &&
(sheet1.ActivePosition.Column == sheet1.MaxColumns - 1))
{
sheet1.ActivePosition =
new GrapeCity.Win.ElTabelle.Position(0, sheet1.ActivePosition.Row + 1);
e.Handled = true;
}
// 最右カラム以外のケース。→ 右セルに移動する。
else if ((sheet1.ActivePosition.Column != sheet1.MaxColumns - 1))
{
sheet1.ActivePosition =
new GrapeCity.Win.ElTabelle.Position(sheet1.ActivePosition.Column + 1, sheet1.ActivePosition.Row);
e.Handled = true;
}
}
}
}
{
if (e.KeyCode == Keys.Enter)
{
if (e.Shift == false){
// 最右カラムでかつ、一番下の行ではない場合は改行する。
if ((sheet1.ActivePosition.Row != sheet1.MaxRows - 1) &&
(sheet1.ActivePosition.Column == sheet1.MaxColumns - 1))
{
sheet1.ActivePosition =
new GrapeCity.Win.ElTabelle.Position(0, sheet1.ActivePosition.Row + 1);
e.Handled = true;
}
// 最右カラム以外のケース。→ 右セルに移動する。
else if ((sheet1.ActivePosition.Column != sheet1.MaxColumns - 1))
{
sheet1.ActivePosition =
new GrapeCity.Win.ElTabelle.Position(sheet1.ActivePosition.Column + 1, sheet1.ActivePosition.Row);
e.Handled = true;
}
}
}
}
この文書は、以前は次のFAQ IDで公開されていました : 9676