Working in a C#/Winforms project, I have derived my own class from DataGridView
so that I can implement several extensions.
One of the extensions I want to implement is a different way of processing the ReadOnly
property. I have implemented a new ReadOnly
property that does what I want, and it's working well, except that all the data bindings to the ReadOnly property are looking at the base DataGridView
ReadOnly
property.
How can I override the data binding as well as the property?
// My implementation of MyGridView
class MyGridView : DataGridView
{
private bool _readOnly=true;
public new bool ReadOnly //shadows property in base class
{
get { return _readOnly; }
set
{
_readOnly = value;
// my custom implementation here
}
}
}
// And the problem is here
// is bound to the base ReadOnly, not the new ReadOnly
labelText.DataBindings.Add("Visible", MyGridView1, "ReadOnly");