You can bind the Width property by doing the following:
label1.DataBindings.Add(new Binding("Text", this, "Width"));
The problem is that the form does not notify the framework that the property has changed. The simplest of your best bets is likely to just do it with meat and potatoes:
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
label1.Text = this.Width.ToString();
}
: , , ( , , ):
DataSource "System.Windows.Forms.Form".
:
public Form2()
{
InitializeComponent();
this.formBindingSource.DataSource = this;
Binding binding = new Binding("Text", this.formBindingSource, "Size", true);
binding.Format += new ConvertEventHandler(binding_Format);
label1.DataBindings.Add(binding);
}
void binding_Format(object sender, ConvertEventArgs e)
{
Size size = (Size)e.Value;
e.Value = size.Width.ToString();
}
, , , .