Series Change Button Causes Exception
Posted: Fri Apr 14, 2023 3:23 pm
Hello,
We've run into an issue where clicking the Change button on the Series tab of the options dialog causes an ArgumentOutOfRangeException. According to our debugging, the ColorPaletteIndex property of the series being changed has a very large value (which was persisted in the v2009 version we were using).
Since we have the source, a fix was made for net472. But because of issues with licensing, we are going to use the net6 version from the published NuGet package so we will need a fix for net6 (though I urge you to fix it for net472 as well).
Here is the relevant call stack:
03/07/2023 15:16:51.33 System.ArgumentOutOfRangeException: InvalidArgument=Value of '2147483647' is not valid for 'SelectedIndex'.
Parameter name: SelectedIndex
at System.Windows.Forms.ComboBox.set_SelectedIndex(Int32 value)
at Steema.TeeChart.Editors.ChartGallery.FillAndShowGallery(TabControl tab, Boolean withFunctions) in D:\p4v\Aspen\3rdParty\Steema.TeeChart\Development_4.2022.11.29\Sources\.NET Framework 4\TeeChart\Editors\Gallery\ChartGallery.cs:line 501
at Steema.TeeChart.Editors.ChartGallery.tabControl2_SelectedIndexChanged(Object sender, EventArgs e) in D:\p4v\Aspen\3rdParty\Steema.TeeChart\Development_4.2022.11.29\Sources\.NET Framework 4\TeeChart\Editors\Gallery\ChartGallery.cs:line 392
at System.Windows.Forms.TabControl.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.TabControl.WmSelChange()
at System.Windows.Forms.TabControl.set_SelectedIndex(Int32 value)
at Steema.TeeChart.Editors.ChartGallery.tabTypes_SelectedIndexChanged(Object sender, EventArgs e) in D:\p4v\Aspen\3rdParty\Steema.TeeChart\Development_4.2022.11.29\Sources\.NET Framework 4\TeeChart\Editors\Gallery\ChartGallery.cs:line 476
at Steema.TeeChart.Editors.ChartGallery.ChartGallery_Load(Object sender, EventArgs e) in D:\p4v\Aspen\3rdParty\Steema.TeeChart\Development_4.2022.11.29\Sources\.NET Framework 4\TeeChart\Editors\Gallery\ChartGallery.cs:line 416
The ColorPaletteIndex value is apparently 2147483647.
Here is the code fix that was made for net472. This is in the ChartGallery.cs file
An official fix for both net472 and more importantly for net6 is requested. I am not certain if this occurs in net6 but if it does, we will need a fix included in a NuGet package.
The basic steps are along these lines. If you need a sample project, I can put one together.
Create a new series. Save the template to a file. Reset the graph and then load the settings previous saved. Open the options dialog and click the Change button to change the series type. This should cause the aforementioned exception.
We've run into an issue where clicking the Change button on the Series tab of the options dialog causes an ArgumentOutOfRangeException. According to our debugging, the ColorPaletteIndex property of the series being changed has a very large value (which was persisted in the v2009 version we were using).
Since we have the source, a fix was made for net472. But because of issues with licensing, we are going to use the net6 version from the published NuGet package so we will need a fix for net6 (though I urge you to fix it for net472 as well).
Here is the relevant call stack:
03/07/2023 15:16:51.33 System.ArgumentOutOfRangeException: InvalidArgument=Value of '2147483647' is not valid for 'SelectedIndex'.
Parameter name: SelectedIndex
at System.Windows.Forms.ComboBox.set_SelectedIndex(Int32 value)
at Steema.TeeChart.Editors.ChartGallery.FillAndShowGallery(TabControl tab, Boolean withFunctions) in D:\p4v\Aspen\3rdParty\Steema.TeeChart\Development_4.2022.11.29\Sources\.NET Framework 4\TeeChart\Editors\Gallery\ChartGallery.cs:line 501
at Steema.TeeChart.Editors.ChartGallery.tabControl2_SelectedIndexChanged(Object sender, EventArgs e) in D:\p4v\Aspen\3rdParty\Steema.TeeChart\Development_4.2022.11.29\Sources\.NET Framework 4\TeeChart\Editors\Gallery\ChartGallery.cs:line 392
at System.Windows.Forms.TabControl.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.TabControl.WmSelChange()
at System.Windows.Forms.TabControl.set_SelectedIndex(Int32 value)
at Steema.TeeChart.Editors.ChartGallery.tabTypes_SelectedIndexChanged(Object sender, EventArgs e) in D:\p4v\Aspen\3rdParty\Steema.TeeChart\Development_4.2022.11.29\Sources\.NET Framework 4\TeeChart\Editors\Gallery\ChartGallery.cs:line 476
at Steema.TeeChart.Editors.ChartGallery.ChartGallery_Load(Object sender, EventArgs e) in D:\p4v\Aspen\3rdParty\Steema.TeeChart\Development_4.2022.11.29\Sources\.NET Framework 4\TeeChart\Editors\Gallery\ChartGallery.cs:line 416
The ColorPaletteIndex value is apparently 2147483647.
Here is the code fix that was made for net472. This is in the ChartGallery.cs file
Code: Select all
private void FillAndShowGallery(TabControl tab, bool withFunctions)
{
gallery.FunctionsVisible = withFunctions;
gallery.View3D = checkBox1.Checked;
if (tab.SelectedTab != null)
{
gallery.CreateGalleryPage(tab.SelectedTab.Text, withFunctions);
gallery.Parent = tab.SelectedTab;
gallery.Dock = DockStyle.Fill;
//annotation line series created in last version of TeeChart has stoopid big ColorPaletteIndex
if (GalleryPanel.ColorPaletteIndex > 1000)
cbGalleryPalette.SelectedIndex = 0; //line type is index=0 in this dialog
else if (GalleryPanel.ColorPaletteIndex > -1)
cbGalleryPalette.SelectedIndex = GalleryPanel.ColorPaletteIndex;
else
cbGalleryPalette.SelectedIndex = 13;
gallery.Show();
}
else gallery.Charts.Clear();
}
The basic steps are along these lines. If you need a sample project, I can put one together.
Create a new series. Save the template to a file. Reset the graph and then load the settings previous saved. Open the options dialog and click the Change button to change the series type. This should cause the aforementioned exception.