i have a MDI Parent as the parent form and i use it to open and organize other forms as child inside it. i use this method to open child forms :
Public Sub OpenForm(ByVal frm As Form)
frm.MdiParent = MainView
frm.Show()
End Sub
the method works correctly and i don't have any problem using it to open child forms. i have 3 items in each child form :
1- DataGridViewX (from DevComponents.DotNetBar.Controls)
2- Panel
3- UserControl
i can use each of these items correctly and no error shows up. DataGridViewX is connected with a DataSource and everything is correct. the problem occurs when i open 2 or more forms inside the MDI Parent and then try to close them. the Error is :
The following exception occurred in the DataGridView:
System.IndexOutOfRangeException: Index 0 does not have a value.
at
System.Windows.Forms.CurrencyManager.get_Item(Int32index)
at
System.Windows.Forms.DataGridView.DataGridViewDataConnection.G" and caption "DataGridView Default Error Dialog".
and this is the code responsible for error :
Partial Class Form1
Inherits DevComponents.DotNetBar.OfficeForm
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()>
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing) '' <<<< ERROR LINE
End Try
End Sub
now obviously i don't code inside designer nor put elements inside form using the code. i use the Designer interface.
what should i do ? thanks
just set binding source of DataGridViewX to nothing and problem solved !
Private Sub theForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
DataGridViewX1.DataSource = Nothing
End Sub