コンボボックス型セルで、ユーザーのアイテム選択で編集を確定するには?
対象製品
El Tabelle for .NET 3.0J
詳細
※ この FAQ のサンプルコードを実行するには、v3.2.2006.0915 以降のアセンブリが必要です。
通常、コンボボックス型セルではユーザーがアイテムを選択しただけでは編集が確定されません。セルからフォーカスが失われるか、あるいは [Enter] キーによって明示的に編集操作が確定される必要があります。
この動作は El Tabelle の仕様ですが、ユーザーがアイテムを選択した直後に、編集を確定し矢印キー等で次のセルに移動したいなどの場合に対応できません。このような処理を行いたい場合、拡張コンボボックス型セルを使用してユーザーがアイテムを選択したイベントを検知し、編集を強制的に確定します。ただし、セルの編集タイプが常時入力モード(AlwaysEdit)の場合は、常に編集モードになっているため、この対応はできません。
WorkBook/Sheet の場合、次のようにコーディングします。
[Visual Basic]
[C#]
MultiRowSheet の場合、次のようにコーディングします。
[Visual Basic]
[C#]
通常、コンボボックス型セルではユーザーがアイテムを選択しただけでは編集が確定されません。セルからフォーカスが失われるか、あるいは [Enter] キーによって明示的に編集操作が確定される必要があります。
この動作は El Tabelle の仕様ですが、ユーザーがアイテムを選択した直後に、編集を確定し矢印キー等で次のセルに移動したいなどの場合に対応できません。このような処理を行いたい場合、拡張コンボボックス型セルを使用してユーザーがアイテムを選択したイベントを検知し、編集を強制的に確定します。ただし、セルの編集タイプが常時入力モード(AlwaysEdit)の場合は、常に編集モードになっているため、この対応はできません。
なお、選択されたアイテムの情報に基づいて処理を行いたい場合については、CellNotifyイベントにおいてActiveCellプロパティを使用して、ユーザーが選択したコンボボックスの値を取得可能です。こちらの操作については製品ヘルプの下記箇所に操作例の記載があります。
WorkBook/Sheet:
El Tabelle for .NET 3.0 の使い方
- セルの操作
- 編集操作のカスタマイズ
MultiRowSheet:
MultiRowSheet の使い方
- 入力の制御
- イベントによる高度な入力制御
WorkBook/Sheet:
El Tabelle for .NET 3.0 の使い方
- セルの操作
- 編集操作のカスタマイズ
MultiRowSheet:
MultiRowSheet の使い方
- 入力の制御
- イベントによる高度な入力制御
WorkBook/Sheet の場合、次のようにコーディングします。
[Visual Basic]
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim objSpComboBoxEditor As GrapeCity.Win.ElTabelle.Editors.SuperiorComboEditor = _
New GrapeCity.Win.ElTabelle.Editors.SuperiorComboEditor
objSpComboBoxEditor.Items.Add("AAA")
objSpComboBoxEditor.Items.Add("BBB")
objSpComboBoxEditor.Items.Add("CCC")
Sheet1(0, 0).Editor = objSpComboBoxEditor
End Sub
Private Sub Sheet1_CellNotify(ByVal sender As Object, _
ByVal e As GrapeCity.Win.ElTabelle.CellNotifyEventArgs) Handles Sheet1.CellNotify
Select Case e.Name
Case GrapeCity.Win.ElTabelle.CellNotifyEvents.SelectedIndexChanged
Sheet1.EditState = False
'または
'Sheet1.KeyAction(GrapeCity.Win.ElTabelle.KeyAction.EndEdit)
Case GrapeCity.Win.ElTabelle.CellNotifyEvents.DropClose
Sheet1.EditState = False
'または
'Sheet1.KeyAction(GrapeCity.Win.ElTabelle.KeyAction.EndEdit)
End Select
End Sub
ByVal e As System.EventArgs) Handles MyBase.Load
Dim objSpComboBoxEditor As GrapeCity.Win.ElTabelle.Editors.SuperiorComboEditor = _
New GrapeCity.Win.ElTabelle.Editors.SuperiorComboEditor
objSpComboBoxEditor.Items.Add("AAA")
objSpComboBoxEditor.Items.Add("BBB")
objSpComboBoxEditor.Items.Add("CCC")
Sheet1(0, 0).Editor = objSpComboBoxEditor
End Sub
Private Sub Sheet1_CellNotify(ByVal sender As Object, _
ByVal e As GrapeCity.Win.ElTabelle.CellNotifyEventArgs) Handles Sheet1.CellNotify
Select Case e.Name
Case GrapeCity.Win.ElTabelle.CellNotifyEvents.SelectedIndexChanged
Sheet1.EditState = False
'または
'Sheet1.KeyAction(GrapeCity.Win.ElTabelle.KeyAction.EndEdit)
Case GrapeCity.Win.ElTabelle.CellNotifyEvents.DropClose
Sheet1.EditState = False
'または
'Sheet1.KeyAction(GrapeCity.Win.ElTabelle.KeyAction.EndEdit)
End Select
End Sub
[C#]
private void Form1_Load(object sender, System.EventArgs e)
{
GrapeCity.Win.ElTabelle.Editors.SuperiorComboEditor objSpComboBoxEditor =
new GrapeCity.Win.ElTabelle.Editors.SuperiorComboEditor();
objSpComboBoxEditor.Items.Add("AAA");
objSpComboBoxEditor.Items.Add("BBB");
objSpComboBoxEditor.Items.Add("CCC");
sheet1[0, 0].Editor = objSpComboBoxEditor;
}
private void sheet1_CellNotify(object sender, GrapeCity.Win.ElTabelle.CellNotifyEventArgs e)
{
switch(e.Name)
{
case GrapeCity.Win.ElTabelle.CellNotifyEvents.SelectedIndexChanged:
sheet1.EditState = false;
//または
//sheet1.KeyAction(GrapeCity.Win.ElTabelle.KeyAction.EndEdit);
break;
case GrapeCity.Win.ElTabelle.CellNotifyEvents.DropClose:
sheet1.EditState = false;
//または
//sheet1.KeyAction(GrapeCity.Win.ElTabelle.KeyAction.EndEdit);
break;
}
}
{
GrapeCity.Win.ElTabelle.Editors.SuperiorComboEditor objSpComboBoxEditor =
new GrapeCity.Win.ElTabelle.Editors.SuperiorComboEditor();
objSpComboBoxEditor.Items.Add("AAA");
objSpComboBoxEditor.Items.Add("BBB");
objSpComboBoxEditor.Items.Add("CCC");
sheet1[0, 0].Editor = objSpComboBoxEditor;
}
private void sheet1_CellNotify(object sender, GrapeCity.Win.ElTabelle.CellNotifyEventArgs e)
{
switch(e.Name)
{
case GrapeCity.Win.ElTabelle.CellNotifyEvents.SelectedIndexChanged:
sheet1.EditState = false;
//または
//sheet1.KeyAction(GrapeCity.Win.ElTabelle.KeyAction.EndEdit);
break;
case GrapeCity.Win.ElTabelle.CellNotifyEvents.DropClose:
sheet1.EditState = false;
//または
//sheet1.KeyAction(GrapeCity.Win.ElTabelle.KeyAction.EndEdit);
break;
}
}
MultiRowSheet の場合、次のようにコーディングします。
[Visual Basic]
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim objSpComboBoxEditor As GrapeCity.Win.ElTabelle.Editors.SuperiorComboEditor = _
New GrapeCity.Win.ElTabelle.Editors.SuperiorComboEditor()
objSpComboBoxEditor.Items.Add("AAA")
objSpComboBoxEditor.Items.Add("BBB")
objSpComboBoxEditor.Items.Add("CCC")
MultiRowSheet1(0, 0, 0).Editor = objSpComboBoxEditor
End Sub
Private Sub MultiRowSheet1_CellNotify(ByVal sender As Object, ByVal e As _
GrapeCity.Win.ElTabelle.CellNotifyEventArgs) Handles Sheet1.CellNotify
Select Case e.Name
Case GrapeCity.Win.ElTabelle.CellNotifyEvents.SelectedIndexChanged
MultiRowSheet1.KeyAction(GrapeCity.Win.ElTabelle.MKeyAction.EndEdit)
Case GrapeCity.Win.ElTabelle.CellNotifyEvents.DropClose
MultiRowSheet1.KeyAction(GrapeCity.Win.ElTabelle.MKeyAction.EndEdit)
End Select
End Sub
ByVal e As System.EventArgs) Handles MyBase.Load
Dim objSpComboBoxEditor As GrapeCity.Win.ElTabelle.Editors.SuperiorComboEditor = _
New GrapeCity.Win.ElTabelle.Editors.SuperiorComboEditor()
objSpComboBoxEditor.Items.Add("AAA")
objSpComboBoxEditor.Items.Add("BBB")
objSpComboBoxEditor.Items.Add("CCC")
MultiRowSheet1(0, 0, 0).Editor = objSpComboBoxEditor
End Sub
Private Sub MultiRowSheet1_CellNotify(ByVal sender As Object, ByVal e As _
GrapeCity.Win.ElTabelle.CellNotifyEventArgs) Handles Sheet1.CellNotify
Select Case e.Name
Case GrapeCity.Win.ElTabelle.CellNotifyEvents.SelectedIndexChanged
MultiRowSheet1.KeyAction(GrapeCity.Win.ElTabelle.MKeyAction.EndEdit)
Case GrapeCity.Win.ElTabelle.CellNotifyEvents.DropClose
MultiRowSheet1.KeyAction(GrapeCity.Win.ElTabelle.MKeyAction.EndEdit)
End Select
End Sub
[C#]
private void Form1_Load(object sender, System.EventArgs e)
{
GrapeCity.Win.ElTabelle.Editors.SuperiorComboEditor objSpComboBoxEditor =
new GrapeCity.Win.ElTabelle.Editors.SuperiorComboEditor();
objSpComboBoxEditor.Items.Add("AAA");
objSpComboBoxEditor.Items.Add("BBB");
objSpComboBoxEditor.Items.Add("CCC");
multiRowSheet1[0, 0, 0].Editor = objSpComboBoxEditor;
}
private void multiRowSheet1_CellNotify(object sender, GrapeCity.Win.ElTabelle.MCellNotifyEventArgs e)
{
switch(e.Name)
{
case GrapeCity.Win.ElTabelle.CellNotifyEvents.SelectedIndexChanged:
multiRowSheet1.KeyAction(GrapeCity.Win.ElTabelle.MKeyAction.EndEdit);
break;
case GrapeCity.Win.ElTabelle.CellNotifyEvents.DropClose:
multiRowSheet1.KeyAction(GrapeCity.Win.ElTabelle.MKeyAction.EndEdit);
break;
}
}
{
GrapeCity.Win.ElTabelle.Editors.SuperiorComboEditor objSpComboBoxEditor =
new GrapeCity.Win.ElTabelle.Editors.SuperiorComboEditor();
objSpComboBoxEditor.Items.Add("AAA");
objSpComboBoxEditor.Items.Add("BBB");
objSpComboBoxEditor.Items.Add("CCC");
multiRowSheet1[0, 0, 0].Editor = objSpComboBoxEditor;
}
private void multiRowSheet1_CellNotify(object sender, GrapeCity.Win.ElTabelle.MCellNotifyEventArgs e)
{
switch(e.Name)
{
case GrapeCity.Win.ElTabelle.CellNotifyEvents.SelectedIndexChanged:
multiRowSheet1.KeyAction(GrapeCity.Win.ElTabelle.MKeyAction.EndEdit);
break;
case GrapeCity.Win.ElTabelle.CellNotifyEvents.DropClose:
multiRowSheet1.KeyAction(GrapeCity.Win.ElTabelle.MKeyAction.EndEdit);
break;
}
}
関連情報
キーワード
HowTo
この文書は、以前は次のFAQ IDで公開されていました : 6990