Is there anyone who knows this?
I tried this last week and no luck.
Now I see that once you can successfully bind the Button Text property, but not its ImageKey property:
myButton.Text = "new text";
myButton.ImageKey = "new text";
I use:
myButton.DataBindings.Add ( new Binding ( "ImageKey", this.MyData, "Name", true, DataSourceUpdateMode.OnPropertyChanged ) );
Why? What makes Binding tick / work? I just do not understand.
EDIT:
OK, so I defined them for my own derived control:
public event EventHandler ImageKeyChanged;
protected virtual void OnImageKeyChanged ( EventArgs e )
{
if ( ImageKeyChanged!= null )
{
ImageKeyChanged ( this, e );
}
}
[Bindable ( true )]
public new string ImageKey
{
get
{
return base.ImageKey;
}
set
{
base.ImageKey = value;
this.OnImageKeyChanged ( EventArgs.Empty );
}
}
It still does not work. Is there a tutorial or something on the net that shows this. It just doesn't work for me.
source
share