why use databinding ?

L

LB

Reading the http://samples.gotdotnet.com/quickstart/winforms/
I'm trying to see the advantage of using "simple data binding".

Let's say I have a treeview loaded from a collection called moList.
On form load, the treeview is loaded. And I bind my textbox to one on the
property
txtLength.DataBindings.Add("Text", moList, "Length")
On the TreeView1 click event, I add the following line :
Me.BindingContext(moList).Position = TreeView1.SelectedNode.Index
Everything is displayed on the form.

But why should I use the DataBindings.Add and BindingContext ?

Couldn't I use directly on the click event directly the following :
txtLength.text = moList.Item(TreeView1.SelectedNode.Index).Length

What's the advantage ?
Thank you for your time
 
G

Guest

if you have more than one textbox and maybe other controls than a textbox you
still only need : "Me.BindingContext(moList).Position =
TreeView1.SelectedNode.Index"

in your case you would endup with one line of code per control..

and then you also need the other way around , send data back from the
controls to your datasource. which would add another line of code per control
for you..

with databinding you only get the above line for navigation..

//Roger
 

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