Strange reaction from a DataGridView
-
I am having a problem I am not sure why is hapening. In the following code, if I put the line with the Clone() method before the this.datagridSplit.Panel2.Controls.Add(dataGrid); it works well but I get the error No parameterless constructor defined for this object in a MissingMethodException. My guess is that is because the object is occupied on another thread but I am not sure. Note that when the dataGrid is added to a control I fire another event that modifies the bound table of the datagrid.:( What a day! public void SetFinder(ref ComplexObject finderObject) //Type ComplexObject is a typed dataset { finderObject.Read(); complexObject = finderObject; dataGrid = finderObject.FinderDatagrid; dataGrid.ColumnHeadersVisible = false; this.datagridSplit.Panel2.Controls.Add(dataGrid); emptyDataSet = finderObject.Clone(); emptyDataSet.EnforceConstraints = false; emptyDataSet.Tables[0].Rows.Add(null, null); emptyDataSet.AcceptChanges(); emptyDataGrid.DataSource = emptyDataSet.Tables[0]; emptyDataGrid.AllowUserToAddRows = false; emptyDataGrid.Dock = DockStyle.Fill; emptyDataGrid.RowHeadersVisible = false; this.datagridSplit.Panel1.Controls.Add(emptyDataGrid); this.emptyDataGrid.CellValueChanged += new DataGridViewCellEventHandler(emptyDataGrid_CellValueChanged); this.emptyDataGrid.CellLeave += new DataGridViewCellEventHandler(emptyDataGrid_CellLeave); }