471,330 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

why use databinding ?

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

Jul 21 '05 #1
1 2906
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

"LB" wrote:
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

Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Kevin Swanson | last post: by
4 posts views Thread by Nathan Sokalski | last post: by
9 posts views Thread by Dennis | last post: by
8 posts views Thread by GaryDean | last post: by
reply views Thread by Wayne Sepega | last post: by
9 posts views Thread by J055 | last post: by
1 post views Thread by =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.