我有一个MDI应用程序,其中MDI表单需要存储绑定源和数据集。儿童表格是"详细表格"因为它们应该允许用户改变父MDI表单数据集中每个对象实例的属性。
我试图按照以下方式进行:
将来自MDI父对象的bindingsource对象传递给新子窗体的构造函数。但是我收到以下错误
"An exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll but was not handled in user code
Additional information: Cannot bind to the property or column Z1 on the DataSource."
Z1是我" Pipe"的公共财产。作为一个对象的类我在visual studio向导中创建了一个数据源。
我的MDI表单代码' Main'
'This is the open child form button click handler
Private Sub ToolStripMenuItem2_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripMenuItem2.Click
Dim p As New PipeForm(Me.PipeBindingSource)
Me.Show(p)
End Sub
'This is the overloaded show helper method for the MDI form
Private Overloads Sub Show(f As Form)
For Each testForm As Form In Application.OpenForms
If testForm.GetType().Equals(f.GetType()) Then
f.Activate()
Return
End If
Next
f.MdiParent = Me
f.Show()
End Sub
我的儿童代码表格' PipeForm'
'constructor
Public Sub New(bs As BindingSource)
' This call is required by the designer.
InitializeComponent()
Me.PipeBindingSource = bs
' Add any initialization after the InitializeComponent() call.
End Sub
我可以在每个表单上有单独的PipeBindingSource对象,并通过文本框输入使用它们,没有任何问题。当我尝试将PipeBindingSource从父级设置为子级相等时会出现问题。