When attempting to add databindings between a simple COM object properties
and text box fields, I get the following error:
Unhandled Exception: System.ArgumentException: Cannot bind to property or
column Id on DataSource.
Parameter name: dataMember
at System.Windows.Forms.BindToObject.CheckBinding()
at
System.Windows.Forms.BindToObject.SetBindingManagerBase(BindingManagerBase
lManager)
at System.Windows.Forms.Binding.SetListManager(BindingManagerBase
bindingManagerBase)
at System.Windows.Forms.ListManagerBindingsCollection.AddCore(Binding
dataBinding)
...
I have a trivial form that contains 3 text boxes (id, first name, last name)
and the form class instantiates the COM object in the constructor. Also in
the constructor, I add the databindings:
public Form1()
{
InitializeComponent();
m_edtId.DataBindings.Add("Text", m_user, "Id");
m_edtLastName.DataBindings.Add("Text", m_user, "LastName");
m_edtFirstName.DataBindings.Add("Text", m_user, "FirstName");
}
The COM object has get/set for these three properties and works fine if I
don't use databinding.
Also, if I replace the COM object with a managed class that has these
properties, I don't have any problems with the databinding.
Thanks for any assistance.