RE: HOW TO: Treeview, obtain the first node index in a sorted Tree

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Kevin,

You should also be able to use the keyvalue in the Nodes() collection. It
looks like you are using "a" & [UC_Code] to denote the key value, so if you
have a query that identify's the root nodes, you should be able to sort that
query alphabetically and determine the [UC_Code] associated with that first
node (I think your varReturn does that). I tried the following from the
debug window in one of my applications, and it expanded the tree to make the
appropriate node ("a123") visible.

me.tvw_Tree.object.nodes("a123").EnsureVisible

HTH
Dale
--
Email address is not valid.
Please reply to newsgroup only.


"Kevin McCartney" wrote:

Ended up cheating by using a query to return the first ancestor and then look
for it in the treeview to return its index.

varRETURN = "a" & Format(DLookup("[UC_CODE]",
"[qselCLIENT_HIERARCHY_FIRST]"), "000000000000")
For Each nodCurrent In objTree.Nodes
If nodCurrent.Key = varRETURN Then
NodeIndex = nodCurrent.Index
Exit For
End If
Next

objTree.Nodes(NodeIndex).EnsureVisible

"Kevin McCartney" wrote:

No that won't work, bjTree.Nodes(1) would be the first item to be added to
the tree and if it the text started with a Z it would appear at the bottom.

What i need is bjTree.Nodes(X), where X is the first item in the tree once
it has been sorted.

Thanks anyway for trying, just hope someone else might have the write answer
and does think this questions is now correctly answered and therefore closed,
so I may have to post the same question again.

"swas" wrote:


Kevin,

Try bjTree.Nodes(1).Root.FirstSibling.EnsureVisible

That should get you there regardless of where bjTree.Nodes(1) is

Regards

swas


"Kevin McCartney" wrote:

Hi TWIMC

I have a treeview that is populated by an query that is sorted so that
parents are added before their associated siblings, thus my source data is
not alphabetically sorted like the treeview appears on the form. Hence is I
use the statement bjTree.Nodes(1).EnsureVisible it doesn't show the viewable
first node in the treeview it shows the node that was added to the treeview
first.

So can anyone tell me what the correct syntax is to ascertain the Index
value of the first 'visible' nodes is, thanks.

I expect it to be simple but I think is one of those, 'Can't see the wood
for the trees'

TIA

KM
.



Relevant Pages

  • RE: HOW TO: Treeview, obtain the first node index in a sorted Tree
    ... Ended up cheating by using a query to return the first ancestor and then look ... for it in the treeview to return its index. ... the tree and if it the text started with a Z it would appear at the bottom. ... "swas" wrote: ...
    (microsoft.public.access.formscoding)
  • Re: Dire TreeView performance in .Net 2.0 vs 1.1
    ... BeginUpdate/EndUpdate route. ... Sadly it makes the tree unusable with it turned ... garbage TreeView control in .Net 2.0 should be summarily shot. ... secs (with BeginUpdate and updating .Text) ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Dire TreeView performance in .Net 2.0 vs 1.1
    ... the tree loads a few thousand nodes rather quickly for me. ... a percentage within its siblings or are the percentages ... TreeView control and the changes appear to be not for the better as far ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: CheckForIllegalCrossThreadCalls
    ... I could not find the FileSystemItem class, but I did create a list of class ... I'll be able to assemble the tree without a problem. ... ..NET PropertyGrid Control - ListBox, ComboBox, and Custom Classes ... not the TreeView control itself. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Deleting a node from TreeView
    ... to store the states, but I'm not sure its worth the effort. ... products on Windows 2000 and some Windows NT systems with 2000 libraries. ... This allows you to open the tree in any state you want it. ... > in a treeview control I'd be eternally grateful! ...
    (microsoft.public.access.formscoding)