473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Data binding question

I have a dataset with tables that map to nodes in a TreeView.

+ Project1 |
+ ConfigA | txtDate
+ Project2 |
+ ConfigB |

On the form that contains the TreeView, there are controls that need to
display other various bits of data associated with each node when the node
is selected in the TreeView. This other data is stored in the same DataSet
in related tables.

So, for example, when I click on Project1, a text box on the form will show
the start date for that project.

I was thinking I could store a struct in the Tag property of each root node
and on NodeMouseClick, throw that structure at a method that updates the
controls of the form.

This means that when the form first opens, as I am creating the node array
for the TreeView from the DataSet, I need to stuff structs in the Tag of
each root node.

Is this utter insanity, or sound reasoning?

One potential complication is a popup form that is supposed to display
further details of the selected project. How would I get the data for that
popup form? Can I store that same struct in some property on the main form
and pass it to the constructor of the popup form when the OpenPopupForm
button is clicked?

Any suggestions welcome...
Mar 5 '06 #1
3 1936
I store structs and / or classes in the Tag property of treenodes all the
time. I've found it to be an excellent approach.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"deko" wrote:
I have a dataset with tables that map to nodes in a TreeView.

+ Project1 |
+ ConfigA | txtDate
+ Project2 |
+ ConfigB |

On the form that contains the TreeView, there are controls that need to
display other various bits of data associated with each node when the node
is selected in the TreeView. This other data is stored in the same DataSet
in related tables.

So, for example, when I click on Project1, a text box on the form will show
the start date for that project.

I was thinking I could store a struct in the Tag property of each root node
and on NodeMouseClick, throw that structure at a method that updates the
controls of the form.

This means that when the form first opens, as I am creating the node array
for the TreeView from the DataSet, I need to stuff structs in the Tag of
each root node.

Is this utter insanity, or sound reasoning?

One potential complication is a popup form that is supposed to display
further details of the selected project. How would I get the data for that
popup form? Can I store that same struct in some property on the main form
and pass it to the constructor of the popup form when the OpenPopupForm
button is clicked?

Any suggestions welcome...

Mar 5 '06 #2
>I store structs and / or classes in the Tag property of treenodes all the
time. I've found it to be an excellent approach.


Well, that's a vote of confidence, anyway.

As for data binding, I looked at that new BindingSource component (recent
dnrTV show on this), but what I'm trying to do just doesn't fit that mold.

There's a whole bunch of data behind each TreeNode. Some is displayed by
child nodes, some is displayed in other controls on the form that hosts the
TreeView, and still more is displayed in a popup from.

If I store a struct containing all this data in each root node's Tag, I can
get the data I need for the controls on the MouseNodeSelect event. As for
the popup form, I need some way to reference the node (that was previously,
but is no longer, selected) when the OpenPopupForm button is clicked. I
could copy the struct from the tag of the node to the tag of the button, but
that seem like a hack.

Anyway, thanks for the reply.
Mar 5 '06 #3

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:4E**********************************@microsof t.com...
I store structs and / or classes in the Tag property of treenodes all the
time. I've found it to be an excellent approach.
Peter


IMHO An even better approach is to derive your own TreeNode and have a
typesafe property instead of using the Tag.

You can also push some of your logic into the node gives you more modular
code:
Pass your business object to the ctor and have it decide the text.
Have a bunch of derived types all implement an interface and you have a nice
way to do polymorphic node click behaviour.

The problem with Tag is that it is not clear which, if any, part of the code
uses it.

The same comments go for ListViewItem only more so because of the subitems.
Mar 5 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Marcin Floryan | last post by:
Hello! My question regards opening (and re-opening) Form and the Load event. I have a main form (frmMain) and I also have a data form (frmData). In the main form I have created: Private...
0
by: Ann Morris | last post by:
INTRODUCTION One of the most powerful aspects of .NET and Windows Forms is data binding. Data binding is the process of associating user interface (UI) elements with a data source to generate a...
16
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For...
1
by: Patrick | last post by:
Hi all, New to .NET, I'm working on an Winforms client application using VS 2005 beta2. My needs considering data storage are the followings: (1) Small files (0 < length < 10 mb), containing...
1
by: matty.hall | last post by:
There's a lot of information out there about data-binding UI objects (i.e. derived from Control) to non-UI custom business objects. Is it possible to do the same without any UI being involved at...
0
by: popsovy | last post by:
Hi I have a question about whether Data Binding can facilitate the process of saving data in a web application I learned that you can data bind information from a number of different data...
10
by: Fares Eidi | last post by:
I am a VB6 intermediate programmer just starting out using VB.net and would like to ask what I'd be missing out on if I just use time saving techniques like data binding, data adapter wizards etc...
2
by: Matthias | last post by:
Hi Team this may be a newbie question. I have searched the discussions before posting: I'd like to re-use a form instance to edit record details. My data binding (a DataTable bound to...
19
by: Larry Lard | last post by:
In the old days (VB3 era), there was a thing called the Data Control, and you could use it to databind controls on forms to datasources, and so (as the marketing speak goes), 'create database...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.