GcComboBoxCellで複数の項目に同じ文字列が設定されている場合、2番目以降の項目を選択することができない
対象製品
MultiRow for Windows Forms 10.0J
詳細
GcComboBoxCellのリストに同じ文字列が複数設定されている場合、2番目以降の項目を選択してセルの編集を終了した後、もう一度リストを開くと1番目の項目が選択された状態になります。
この動作は仕様に基づく動作になります。
この動作は、グリッドのCellParsingイベントと編集用のGcComboBoxEditingControlのDropDownOpenedイベントで明示的に値を設定することで回避することができます。
[Visual Basic]
[C#]
この動作は仕様に基づく動作になります。
この動作は、グリッドのCellParsingイベントと編集用のGcComboBoxEditingControlのDropDownOpenedイベントで明示的に値を設定することで回避することができます。
[Visual Basic]
Imports GrapeCity.Win.MultiRow Imports InputManCell = GrapeCity.Win.MultiRow.InputMan Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load ' セル型の設定 Dim comboCell As New InputManCell.GcComboBoxCell() comboCell.Name = "comboCell" comboCell.ListColumns.Add("Code") comboCell.ListColumns.Add("Name") comboCell.ListColumns.Add("Key") comboCell.ListColumns(2).Visible = False comboCell.Items.Add(New InputManCell.ListItem(New InputManCell.SubItem() { New InputManCell.SubItem("AAA"), New InputManCell.SubItem("A1"), New InputManCell.SubItem("1")})) comboCell.Items.Add(New InputManCell.ListItem(New InputManCell.SubItem() { New InputManCell.SubItem("AAA"), New InputManCell.SubItem("A2"), New InputManCell.SubItem("2")})) comboCell.Items.Add(New InputManCell.ListItem(New InputManCell.SubItem() { New InputManCell.SubItem("AAA"), New InputManCell.SubItem("A3"), New InputManCell.SubItem("3")})) comboCell.Items.Add(New InputManCell.ListItem(New InputManCell.SubItem() { New InputManCell.SubItem("BBB"), New InputManCell.SubItem("B1"), New InputManCell.SubItem("4")})) comboCell.Items.Add(New InputManCell.ListItem(New InputManCell.SubItem() { New InputManCell.SubItem("BBB"), New InputManCell.SubItem("B2"), New InputManCell.SubItem("5")})) comboCell.TextSubItemIndex = 0 comboCell.ValueSubItemIndex = 2 ' MultiRowの設定 GcMultiRow1.Template = Template.CreateGridTemplate(New Cell() {comboCell}) GcMultiRow1.RowCount = 5 End Sub ' 回避方法 - Start Private Sub GcMultiRow_CellParsing(sender As System.Object, e As CellParsingEventArgs) Handles GcMultiRow1.CellParsing If e.CellName = "comboCell" Then If Me.GcMultiRow1.EditingControl IsNot Nothing Then If TryCast(Me.GcMultiRow1.EditingControl, InputMan.GcComboBoxEditingControl).SelectedValue IsNot Nothing Then e.Value = TryCast(Me.GcMultiRow1.EditingControl, InputMan.GcComboBoxEditingControl).SelectedValue e.ParsingApplied = True End If End If End If End Sub Private Sub GcMultiRow_EditingControlShowing(sender As Object, e As GrapeCity.Win.MultiRow.EditingControlShowingEventArgs) Handles GcMultiRow1.EditingControlShowing TryCast(e.Control, InputMan.GcComboBoxEditingControl).ValueSubItemIndex = TryCast(Me.GcMultiRow1.CurrentCell, InputMan.GcComboBoxCell).ValueSubItemIndex TryCast(e.Control, InputMan.GcComboBoxEditingControl).SelectedValue = Me.GcMultiRow1.CurrentCell.Value RemoveHandler TryCast(e.Control, InputMan.GcComboBoxEditingControl).SelectedIndexChanged, AddressOf Me.GcComboBox_SelectedIndexChanged AddHandler TryCast(e.Control, InputMan.GcComboBoxEditingControl).SelectedIndexChanged, AddressOf Me.GcComboBox_SelectedIndexChanged End Sub Private Sub GcComboBox_SelectedIndexChanged(sender As Object, e As System.EventArgs) Me.GcMultiRow1.NotifyCurrentCellDirty(True) End Sub ' 回避方法 - End
[C#]
using GrapeCity.Win.MultiRow; using InputManCell = GrapeCity.Win.MultiRow.InputMan; private void Form1_Load(object sender, EventArgs e) { // セル型の設定 InputManCell.GcComboBoxCell comboCell = new InputManCell.GcComboBoxCell(); comboCell.Name = "comboCell"; comboCell.ListColumns.Add("Code"); comboCell.ListColumns.Add("Name"); comboCell.ListColumns.Add("Key"); comboCell.ListColumns[2].Visible = false; comboCell.Items.Add(new InputManCell.ListItem(new InputManCell.SubItem[] { new InputManCell.SubItem("AAA"), new InputManCell.SubItem("A1"), new InputManCell.SubItem("1")})); comboCell.Items.Add(new InputManCell.ListItem(new InputManCell.SubItem[] { new InputManCell.SubItem("AAA"), new InputManCell.SubItem("A2"), new InputManCell.SubItem("2")})); comboCell.Items.Add(new InputManCell.ListItem(new InputManCell.SubItem[] { new InputManCell.SubItem("AAA"), new InputManCell.SubItem("A3"), new InputManCell.SubItem("3")})); comboCell.Items.Add(new InputManCell.ListItem(new InputManCell.SubItem[] { new InputManCell.SubItem("BBB"), new InputManCell.SubItem("B1"), new InputManCell.SubItem("4")})); comboCell.Items.Add(new InputManCell.ListItem(new InputManCell.SubItem[] { new InputManCell.SubItem("BBB"), new InputManCell.SubItem("B2"), new InputManCell.SubItem("5")})); comboCell.TextSubItemIndex = 0; comboCell.ValueSubItemIndex = 2; // MultiRowの設定 gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] {comboCell}); gcMultiRow1.RowCount = 5; gcMultiRow1.CellParsing += gcMultiRow1_CellParsing; gcMultiRow1.EditingControlShowing += gcMultiRow1_EditingControlShowing; } // 回避方法 - Start private void gcMultiRow1_CellParsing(object sender, CellParsingEventArgs e) { if(e.CellName == "comboCell") { if ( gcMultiRow1.EditingControl != null) { if((gcMultiRow1.EditingControl as InputManCell.GcComboBoxEditingControl).SelectedValue != null) { e.Value = (gcMultiRow1.EditingControl as InputManCell.GcComboBoxEditingControl).SelectedValue; e.ParsingApplied = true; } } } } private void gcMultiRow1_EditingControlShowing(object sender, EditingControlShowingEventArgs e) { (e.Control as InputManCell.GcComboBoxEditingControl).ValueSubItemIndex = (gcMultiRow1.CurrentCell as InputManCell.GcComboBoxCell).ValueSubItemIndex; (e.Control as InputManCell.GcComboBoxEditingControl).SelectedValue = gcMultiRow1.CurrentCell.Value; (e.Control as InputManCell.GcComboBoxEditingControl).SelectedIndexChanged -= new EventHandler(GcComboBox_SelectedIndexChanged); (e.Control as InputManCell.GcComboBoxEditingControl).SelectedIndexChanged += new EventHandler(GcComboBox_SelectedIndexChanged); } private void GcComboBox_SelectedIndexChanged(object sender, EventArgs e) { gcMultiRow1.NotifyCurrentCellDirty(true); } // 回避方法 - End