T
Tony Johansson
Hello!
Here I use the Binding object to bind the text property of a TextBox control
txtName to the Name property of the product object
Product product = new Product("Apple", 17.19, 2);
Binding binding = new Binding("Text", product, "Name", true);
txtName.DataBindings.Add(binding);
The Binding object requires the following information:
- Name of the property of the control to which the binding is to done (e.g
Text Property
of a TextBox).
- Data source (the object product in the above example)
- The name of the property in the data source to which the property of the
control is to
be bound (Name in the above example, product.Name)
But I can also write in this way and skip the Binding object.
txtName.DataBinding.Add("Text", new Product("Apple", 17.19, 2), "Name");
Now to my question as you can see here I didn't use the Binding object at
all in the last example
so when is it nesessary to use this Binding object that I used in the first
example ?
//Tony
Here I use the Binding object to bind the text property of a TextBox control
txtName to the Name property of the product object
Product product = new Product("Apple", 17.19, 2);
Binding binding = new Binding("Text", product, "Name", true);
txtName.DataBindings.Add(binding);
The Binding object requires the following information:
- Name of the property of the control to which the binding is to done (e.g
Text Property
of a TextBox).
- Data source (the object product in the above example)
- The name of the property in the data source to which the property of the
control is to
be bound (Name in the above example, product.Name)
But I can also write in this way and skip the Binding object.
txtName.DataBinding.Add("Text", new Product("Apple", 17.19, 2), "Name");
Now to my question as you can see here I didn't use the Binding object at
all in the last example
so when is it nesessary to use this Binding object that I used in the first
example ?
//Tony