Page 1 of 1

Series Change Button Causes Exception

Posted: Fri Apr 14, 2023 3:23 pm
by 16095093
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

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();
        }
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.

Re: Series Change Button Causes Exception

Posted: Mon Apr 17, 2023 9:52 am
by Christopher
Hello Kris,
Kris C wrote:
Fri Apr 14, 2023 3:23 pm
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.
As you can see here:
https://steema.com/files/public/support ... 37-18.webm

Running the following code against the latest public NuGet:

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }

        private void InitializeChart()
        {
            var line = new Line(tChart1.Chart);
            line.FillSampleValues();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            tChart1.ShowEditor();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            var export = tChart1.Export.Template;
            var stream = new MemoryStream();

            export.Save(stream);
            tChart1.Clear();
            MessageBox.Show("Cleared!");

            var import = tChart1.Import.Template;
            stream.Position = 0;
            import.Load(stream);

            tChart1[0].FillSampleValues();
        }
Doesn't reproduce the problem. Notwithstanding, I've added this enhancement to our issue tracker with id=2604 and have resolved it, albeit in a slightly different way to yours. This fix will be available in the next public NuGet release.

Re: Series Change Button Causes Exception

Posted: Mon Apr 17, 2023 4:40 pm
by 16095093
Thank you, Christopher. Looking forward to the next NuGet package version.

Kris