Reputation: 800
I am sorry if this is a duplicate, but I searched the net and haven't found an answer
I am trying to bind the control's Enabled
(or ReadOnly
for TextBox
):
this.tbProj.DataBindings.Add(new Binding("Enabled", this, "CanEdit", false, DataSourceUpdateMode.OnPropertyChanged, false));
this.btnSave.DataBindings.Add(new Binding("Enabled", this, "Dirty", false, DataSourceUpdateMode.OnPropertyChanged, false));
To the following properties:
public bool Dirty { get; set; }
private bool CanEdit
{
get { return this._CurrentRecord.CanEdit(); }
}
I get System.ArgumentException: Cannot bind to the property or column CanEdit on the DataSource.
when trying to ShowDialog()
the form.
If I bind the Enabled
or ReadOnly
to Dirty
, everything forks fine. I tried get { return true; }
and even added a setter: set { bool bummy=value; }
, same error. I even changed CanEdit
to an auto-implemented property, same as Dirty
(just get; set;
in declaration) at no avail...
Please help.
Thanks for any hints and advice.
Upvotes: 3
Views: 1042
Reputation: 81620
The property has to be public:
public bool CanEdit
{
get { return this._CurrentRecord.CanEdit(); }
}
Upvotes: 3