作成日: 2019/02/13 最終更新日: 2019/04/17
文書種別
不具合
状況
修正済み
詳細
実行時にGcComboBoxコントロールをコードで動的に生成してページに追加している場合や、GcComboBoxコントロールを.NETのRepeaterコントロール内で使用している場合、GcComboBoxコントロールのドロップダウンリストにアイテムが一つでもあると、ページをポストバックしたときに例外が発生します。
WebフォームにGcComboBoxと.NET標準のButtonコントロールを配置し、下記のサンプルコードを記述してデバッグ実行後にButton押下で現象が確認可能です。
【再現コード】
[Visual Basic]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
For i As Integer = 0 To 2
Dim combo As New GrapeCity.Web.Input.IMCombo.GcComboBox()
combo.Items.Clear()
combo.LoadDataDynamically = True
combo.RecordsPerRequest = 50
combo.ListBox.MaxItems = 20
For j As Integer = 0 To 9
combo.Items.Add(String.Format("A{0}", j))
Next
combo.Value = String.Format("A{0}", i)
Page.Form.Controls.Add(combo)
Next
End Sub
[C#]
protected void Page_Load(object sender, EventArgs e)
{
for(int i = 0; i < 3; i++)
{
GrapeCity.Web.Input.IMCombo.GcComboBox combo = new GrapeCity.Web.Input.IMCombo.GcComboBox();
combo.Items.Clear();
combo.LoadDataDynamically = true;
combo.RecordsPerRequest = 50;
combo.ListBox.MaxItems = 20;
for (int j = 0; j < 10; j++)
{
combo.Items.Add(String.Format("A{0}", j));
}
combo.Value = String.Format("A{0}", i);
Page.Form.Controls.Add(combo);
}
}
WebフォームにGcComboBoxと.NET標準のButtonコントロールを配置し、下記のサンプルコードを記述してデバッグ実行後にButton押下で現象が確認可能です。
【再現コード】
[Visual Basic]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
For i As Integer = 0 To 2
Dim combo As New GrapeCity.Web.Input.IMCombo.GcComboBox()
combo.Items.Clear()
combo.LoadDataDynamically = True
combo.RecordsPerRequest = 50
combo.ListBox.MaxItems = 20
For j As Integer = 0 To 9
combo.Items.Add(String.Format("A{0}", j))
Next
combo.Value = String.Format("A{0}", i)
Page.Form.Controls.Add(combo)
Next
End Sub
[C#]
protected void Page_Load(object sender, EventArgs e)
{
for(int i = 0; i < 3; i++)
{
GrapeCity.Web.Input.IMCombo.GcComboBox combo = new GrapeCity.Web.Input.IMCombo.GcComboBox();
combo.Items.Clear();
combo.LoadDataDynamically = true;
combo.RecordsPerRequest = 50;
combo.ListBox.MaxItems = 20;
for (int j = 0; j < 10; j++)
{
combo.Items.Add(String.Format("A{0}", j));
}
combo.Value = String.Format("A{0}", i);
Page.Form.Controls.Add(combo);
}
}
回避方法
Service Pack 3(v10.0.4003.2012)で修正済み。
Service Pack を適用せずに対処する方法としては、必要な数のコントロールをデザイン時にあらかじめフォームに配置するか、実行時に動的に生成する場合は、コントロール生成時に、ドロップダウンリストに列を新規に追加することで現象を回避可能です。
以下は、再現コードに回避策を適用した例です。
【サンプルコード】
[Visual Basic]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
For i As Integer = 0 To 2
Dim combo As New GrapeCity.Web.Input.IMCombo.GcComboBox()
combo.Items.Clear()
' コントロールに列を追加します
combo.ListBox.Columns.Add(New GrapeCity.Web.Input.Core.ListBox.ListColumn())
combo.LoadDataDynamically = True
combo.RecordsPerRequest = 50
combo.ListBox.MaxItems = 20
' 列幅を調整します
combo.ListBox.Columns(0).Width = 130
' ドロップダウンリストの水平スクロールバーを隠します
combo.ListBox.ScrollBars = GrapeCity.Web.Input.Core.ScrollBars.Vertical
For j As Integer = 0 To 9
combo.Items.Add(String.Format("A{0}", j))
Next
combo.Value = String.Format("A{0}", i)
Page.Form.Controls.Add(combo)
Next
End Sub
[C#]
protected void Page_Load(object sender, EventArgs e)
{
for(int i = 0; i < 3; i++)
{
GrapeCity.Web.Input.IMCombo.GcComboBox combo = new GrapeCity.Web.Input.IMCombo.GcComboBox();
combo.Items.Clear();
// コントロールに列を追加します
combo.ListBox.Columns.Add(new GrapeCity.Web.Input.Core.ListBox.ListColumn());
combo.LoadDataDynamically = true;
combo.RecordsPerRequest = 50;
combo.ListBox.MaxItems = 20;
// 列幅を調整します
combo.ListBox.Columns[0].Width = 130;
// ドロップダウンリストの水平スクロールバーを隠します
combo.ListBox.ScrollBars = GrapeCity.Web.Input.Core.ScrollBars.Vertical;
for (int j = 0; j < 10; j++)
{
combo.Items.Add(String.Format("A{0}", j));
}
combo.Value = String.Format("A{0}", i);
Page.Form.Controls.Add(combo);
}
}
Service Pack を適用せずに対処する方法としては、必要な数のコントロールをデザイン時にあらかじめフォームに配置するか、実行時に動的に生成する場合は、コントロール生成時に、ドロップダウンリストに列を新規に追加することで現象を回避可能です。
以下は、再現コードに回避策を適用した例です。
【サンプルコード】
[Visual Basic]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
For i As Integer = 0 To 2
Dim combo As New GrapeCity.Web.Input.IMCombo.GcComboBox()
combo.Items.Clear()
' コントロールに列を追加します
combo.ListBox.Columns.Add(New GrapeCity.Web.Input.Core.ListBox.ListColumn())
combo.LoadDataDynamically = True
combo.RecordsPerRequest = 50
combo.ListBox.MaxItems = 20
' 列幅を調整します
combo.ListBox.Columns(0).Width = 130
' ドロップダウンリストの水平スクロールバーを隠します
combo.ListBox.ScrollBars = GrapeCity.Web.Input.Core.ScrollBars.Vertical
For j As Integer = 0 To 9
combo.Items.Add(String.Format("A{0}", j))
Next
combo.Value = String.Format("A{0}", i)
Page.Form.Controls.Add(combo)
Next
End Sub
[C#]
protected void Page_Load(object sender, EventArgs e)
{
for(int i = 0; i < 3; i++)
{
GrapeCity.Web.Input.IMCombo.GcComboBox combo = new GrapeCity.Web.Input.IMCombo.GcComboBox();
combo.Items.Clear();
// コントロールに列を追加します
combo.ListBox.Columns.Add(new GrapeCity.Web.Input.Core.ListBox.ListColumn());
combo.LoadDataDynamically = true;
combo.RecordsPerRequest = 50;
combo.ListBox.MaxItems = 20;
// 列幅を調整します
combo.ListBox.Columns[0].Width = 130;
// ドロップダウンリストの水平スクロールバーを隠します
combo.ListBox.ScrollBars = GrapeCity.Web.Input.Core.ScrollBars.Vertical;
for (int j = 0; j < 10; j++)
{
combo.Items.Add(String.Format("A{0}", j));
}
combo.Value = String.Format("A{0}", i);
Page.Form.Controls.Add(combo);
}
}
旧文書番号
83632