Manual DataSource Causes Exception

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Kris C
Newbie
Newbie
Posts: 59
Joined: Fri Jan 13, 2023 12:00 am

Manual DataSource Causes Exception

Post by Kris C » Tue Jun 20, 2023 2:59 pm

Hello,

Attached is a very simple sample project that reproduces an exception when changing the datasource to "manual" under Series/Datasource in the options dialog.

Extract and open the solution in VS2022. Turn "on" exceptions by ticking on the "Common Language Runtime" in the exceptions docking window. Run it (it uses the latest TeeChart NuGet package) without debugger attached. Click the Options button, go to Series / Datasource and switch the drop-down to Manual.

I've tracked the issue down to the code using DataBindings.Add with a DataGridView instead of just assigning the Datasource property to the DataTable.

Kind Regards,

Kris Culin
Bentley Systems, Inc.
Attachments
TeeChartUnhandledException.png
Image of unhandled exception
TeeChartUnhandledException.png (23.6 KiB) Viewed 14810 times
TeeChartNET60.zip
Sample project
(7.28 KiB) Downloaded 1039 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Manual DataSource Causes Exception

Post by Christopher » Tue Jun 20, 2023 4:18 pm

Hello Kris,

thank you for the bug report, as is standard procedure we can add these reports directly to our issue tracker, as I have done in this case with id=2615.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Manual DataSource Causes Exception

Post by Christopher » Tue Jun 20, 2023 4:34 pm

Hello Kris,

this is now fixed, and the diff for you to fix the sourcecode, if you so wish, is this:

Code: Select all

diff --git a/TeeChart.PCL.NET5/TeeChart.WinForm/Editors/Series/SeriesEditor.cs b/TeeChart.PCL.NET5/TeeChart.WinForm/Editors/Series/SeriesEditor.cs
index 225fb07d..a4641a3d 100644
--- a/TeeChart.PCL.NET5/TeeChart.WinForm/Editors/Series/SeriesEditor.cs
+++ b/TeeChart.PCL.NET5/TeeChart.WinForm/Editors/Series/SeriesEditor.cs
@@ -793,7 +793,11 @@ namespace Steema.TeeChart.Editors
                             if (data.Tables.Count == 1)
                             {
                                 dataTable = data.Tables[0];
-                                dataGrid1.DataBindings.Add(dataTable.TableName, data, dataTable.TableName);
+                                var binder = new BindingSource
+                                {
+                                    DataSource = dataTable
+                                };
+                                dataGrid1.DataSource = binder;
                                 dataTable.RowChanged += new System.Data.DataRowChangeEventHandler(dataGrid1_DataSourceChanged);
                             }
                         }
@@ -801,7 +805,11 @@ namespace Steema.TeeChart.Editors
                         {
                             data = series.GetChartData();
                             dataTable = data.Tables[0];
-                            dataGrid1.DataBindings.Add(dataTable.TableName, data, dataTable.TableName);
+                            var binder = new BindingSource
+                            {
+                                DataSource = dataTable
+                            };
+                            dataGrid1.DataSource = binder;
                             dataTable.RowChanged += new System.Data.DataRowChangeEventHandler(dataGrid1_DataSourceChanged);
                         }
                     }

Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Kris C
Newbie
Newbie
Posts: 59
Joined: Fri Jan 13, 2023 12:00 am

Re: Manual DataSource Causes Exception

Post by Kris C » Tue Jun 20, 2023 5:22 pm

Thank you, Christopher, for the quick turnaround. I'll make our change consistent with yours.

Kind Regards,

Kris Culin
Bentley Systems, Inc.

Post Reply