On 04-Mar-11 12:15, Tony Johansson wrote:
>
> Product product = new Product("Apple", 17.19, 2);
> Binding binding = new Binding("Text", product, "Name", true);
> txtName.DataBindings.Add(binding);
>
<snip>
>
> 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 ?
>
The latter version of Add constructs a Binding object for you from the
information provided, and returns it to you. If you're not going to use
the Binding object you can simply ignore the return value. So all in
all, it provides the same functionality, with less plumbing.
The end result is the same, only the road to it differs.
--
Willem van Rumpt
|