We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Removing grid from parent control

I am receiving a wierd error when removing a GDBG from a parent control (panel). The binding context is changing and throwing an error. Why would the binding contaxt be changing???? To make matters worse, the error is only being thrown on some machines. Below is a stack track and the error received. Thanks in advance for any help. Virgil Line throwing the error: Me.pnlGrid.Controls.Remove(_Grid) Error information: EndItem ID: 20787 EndItem #: qpart1139 EndItem Desc.: Muggles Error: There is no row at position 0. Stack Trace 6/27/2005 11:52:18 AM at System.Data.DataView.GetRecord(Int32 recordIndex) at System.Data.DataView.IsOriginalVersion(Int32 index) at System.Data.DataRowView.SetColumnValue(DataColumn column, Object value) at System.Data.DataColumnPropertyDescriptor.SetValue(Object component, Object value) at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.CancelEdit() at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.RefreshRows(CurrencyManager bmb) at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.Set_ListManager(Object newDataSource, String newDataMember, Boolean force, Boolean forceColumnCreation) at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.OnBindingContextChanged(EventArgs e) at Syncfusion.Windows.Forms.Grid.GridDataBoundGrid.OnBindingContextChanged(EventArgs e) at System.Windows.Forms.Control.AssignParent(Control value) at System.Windows.Forms.ControlCollection.Remove(Control value) at WinCES.EndItemGrid.BindDataGrid(DataSet SourceData, Boolean DisplayAfterBindingIsComplete) in C:\Projects\Lear\WinCES\WinCES\EndItemGrid.vb:line 1385 at WinCES.EndItemGrid.RebuildGrid() in C:\Projects\Lear\WinCES\WinCES\EndItemGrid.vb:line 7673

2 Replies

AD Administrator Syncfusion Team June 27, 2005 06:09 PM UTC

The bindingcontext is normally inherited from the parent when the control is parented. So, the parent can play a role in bindingcontexts. One thing you can try is to set the grid.DataSource = null before you remove it from its parent.COntrols collection to see if this takes care of the problem.

VI Virgil June 27, 2005 08:29 PM UTC

That works. I also had to do the other things normally associated with rebinding the grid to a new datasource (Datamember=null and ResetHierarchyLevels) prior to re-hooking up the datasource.

Live Chat Icon For mobile
Up arrow icon