Re: More Treeview questions



We agree to disagree on that one. There are all sorts
of business cases for us where using my approach
works out great. It drastically improved our
code reusability in some areas.

That said, I recognize it is not a one size fits all
approach to managing UI to data functionality.
In 2005, generics have helped us in this area
as well.

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.eggheadcafe.com/forums/merit.asp





"Rick Elbers" <rick.elbers@xxxxxxxxx> wrote in message
news:oh0op15q3uld4ff53pho1vvoi55a1mgmjo@xxxxxxxxxx
> Two comments,
>
> 1) dont use c style casts if there is a better alternative.
> The better alternative is to create some sort union using
> implicit cast operators, then in the client use
>
> CustomObject obj = tvTre.SelectedNode.Tag as CustomObject;
> if (obj == null)
> //handle programmer errors with at least an ASSERT.
>
> 2) Databinding of a tree is an absurd idea, which reminds me at
> basic datastructure class. A tree is nothing but nodes like a
> list. In fact the best bst tree implementation is a skip list:-)
>
> So, what does this mean ? You can't ever want to databind
> a tree( which is nothing anyway) Its genericity stops when you have
> nodes from more then one table(see:
> http://www.eggheadcafe.com/articles/treeview_databinding.asp)
>
> If you want to bind all nodes then the best approach seems
> to use a prototype tree of different nodetypes and construct
> new nodes from the prototype( see the pattern of the same name).
> Identifie your prototypenodes with for instance an enum.
>
> Then implement childdatabinding in the node. You can give the
> node a table, tableadapter and adaptermethod and basically
> you have databinding of the childnodes. Store the keyvalues in the
> node. Add things for adaptermethods with parameters. Make selectors
> from value( Where city = "Wageningen") or selectors from parent nodes
> (Where city = @City), the last simply implemented by passing the
> node's identifier level( see above)
>
>
>
> Rick
>
>
>
>
>
>
>
>
> On Sat, 10 Dec 2005 17:01:45 -0500, "Robbe Morris [C# MVP]"
> <info@xxxxxxxxxxxxxxx> wrote:
>
>>People typically create a small custom struct or
>>class with the properties they want exposed and
>>place it in the .Tag property.
>>
>>When they select a node, they get node,
>>
>>CustomItem test = (CustomItem)tvTree.SelectedNode.Tag;
>>
>>Debug.WriteLine(test.WhateverMyPropertyWas);
>>
>>You can also do this with datarows and institute
>>a sort of databinding.
>>
>>http://www.eggheadcafe.com/articles/treeview_databinding.asp
>


.



Relevant Pages

  • Re: Vertigo warnings on BBC
    ... the term has come to encompass any sort of height related problems. ... Instead the bosses asked me to stay and agreed no more tree work for ... I'd be doing a high hedge, ... Eventually I went to my then north London doctor and told him. ...
    (uk.media.tv.misc)
  • Re: 3 Year-old live oak..Whats wrong w/ my tree?
    ... I think your oak is infested with some sort of scale insect. ... If your tree is small enough and you are determined to protect it, ...
    (rec.gardens)
  • "Undocumented Extensions" (was: If you were inventing CoBOL...
    ... For an example of exactly HOW many undocumented extensions IBM dropped support ... The structures are actually lists ... > in the unbalanced tree while you're sorting. ... > putting the logic in a library called by the SORT verb. ...
    (comp.lang.cobol)
  • Re: More Treeview questions
    ... The better alternative is to create some sort union using ... CustomObject obj = tvTre.SelectedNode.Tag as CustomObject; ... Databinding of a tree is an absurd idea, ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Technical and Spiritual Development
    ... >> you something other than humans. ... Tree Of Life was the yamlike root that converted a breeder Pak ... but I hate that sort of revisionism - it's like what ...
    (sci.space.history)