You forgot the quotes around the property name:
txtBoundFormProperty.DataBindings.Add("Text" , this, "FormProperty");
~~Bonnie
>Bonnie,
>
>In the class definition:
>
>public string formProperty;
>public string FormProperty
> {
> get { return formProperty; }
> set { formProperty = value; }
> }
>
>
>In the forms constructor:
>
>InitializeComponent();
>FormProperty = "hello world";
>txtBoundFormProperty.DataBindings.Add("Text" , this,
> FormProperty);
>
>
>Getting an exception: Cannot bind to property or column hello world on DataSource.
>Parameter name: dataMember. I've also tried to issue formProperty as the last parameter to DataBindings.Add(). Tried to make formProperty private, same result.
>
>Thanks,
>steve
>
>
>>Yep, you can bind to a property ... but make sure it's a public *property* (with a get/set) and not simply a field (public or otherwise).
>>
>>MyTextBox.DataBindings.Add("Text", this, "MyProperty");
>>
>>
>>~~Bonnie
>>
>>
>>>Learning how to bind controls to objects is giving me fits. It seems that you can only bind a control to an Array (or other collection using the IList interface), or a DataSet (and DataTable, I suppose).
>>>
>>>What if I want to bind textBox.text to a property of a form, or a member of some other class. Can that be done?
>>>
>>>Thanks again,