Page 1 of 1

Manual DataSource Causes Exception

Posted: Tue Jun 20, 2023 2:59 pm
by 16095093
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.

Re: Manual DataSource Causes Exception

Posted: Tue Jun 20, 2023 4:18 pm
by Christopher
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.

Re: Manual DataSource Causes Exception

Posted: Tue Jun 20, 2023 4:34 pm
by Christopher
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);
                         }
                     }


Re: Manual DataSource Causes Exception

Posted: Tue Jun 20, 2023 5:22 pm
by 16095093
Thank you, Christopher, for the quick turnaround. I'll make our change consistent with yours.

Kind Regards,

Kris Culin
Bentley Systems, Inc.