I want to create a bindable property for a button class that is derived from System.Windows.Forms.Button.
Code:class MyButton : System.Windows.Forms.Button { public MyButton() { } int _bExternalOn = 0; [System.ComponentModel.Bindable(true)] public int ExternalCmd { set { _bExternalOn = value; } get { return _bExternalOn; } } } //in form, button1 is an instance of MyButton public partial class Form1 : Form { public Form1() { InitializeComponent(); button1.DataBindings.Add(new Binding("ExternalCmd", testSrc, "SRC_VALUE")); } Src testSrc = new Src(); public class Src { int nVal = 0; public int SRC_VALUE { get { return nVal; } set { nVal = value; } } } private void button2_Click(object sender, EventArgs e) { button1.ExternalCmd = 66;//testSrc.SRC_VALUE should show 66 now as this is bind to button1.ExternalCmd , but it doesn;'t. why?? } }




Reply With Quote