Reputation: 13
How can I bind the Property (Location.X) of a C# button to a BindingSource?
I have tried the following code
myButton.DataBindings.Add("Location.X", myButtonsBindingSource, "Button_X");
but it is not working, it works for example if I want to bind the Text property of the button but not for X & Y coordinators.
any ideas or other ways to bind Location.X property of my button to a binding source programmatically?
Thanks
Upvotes: 0
Views: 541
Reputation: 125197
You can use Left
property of the button instead:
myButton.DataBindings.Add("Left", myButtonsBindingSource, "Button_X");
Above statement creates a data-binding between Button_X
property of the object which you have in DataSource
of myButtonsBindingSource
and Left
property of myButton
.
Upvotes: 1