Binding Property "Size" Works But Not "Width" -- Please Explain

T

Tom

Can someone please explain the non-working aspect of binding to Width?
See code below.

Thanks !!

-- Tom
===================================================

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

public class FormParent : Form
{
[STAThread]
public static void Main()
{
Application.EnableVisualStyles();
Application.Run(new FormParent());
}
FormParent()
{
Text = "The Parent Form";

Form FormChild = new Form();
FormChild.Text = "The Child Form";
FormChild.Show();

// The following works!! :)
FormChild.DataBindings.Add("Size", this, "Size");

// The following does NOT! :(
//FormChild.DataBindings.Add("Width", this, "Width");
}
}
 
M

Marc Gravell

Simple; bindings depend on change-notification for the "observer"
behavior. The simplest form of this is a {property name}Changed event.
There *is* a SizeChanged event, but there *isn't* a WidthChanged
event. The binding will look for a suitable event and attempt to
subscribe if possible (usually via the PropertyDescriptor). However,
it can't do this for Width as it can't find a suitable notification
mechanism.

Marc
 
T

Tom

Thanks Marc --

That hits like a lightnin bolt!!

I'm just now exploring bindings and I tripped on the first obstacle!!

I appreciate your help.

Happy Holidays.

-- Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top