Solved

Treeview question - easy!

Posted on 2002-07-18
10
122 Views
Last Modified: 2010-05-02
Once choosing an item in treeview, it populates the child nodes but on a long list you see the bottom of the list.  I want to expand it, but stay at the top (where the parent is) not at the bottom of the children.  How do I do it?
0
Comment
Question by:jackjeckyl
  • 4
  • 3
10 Comments
 
LVL 4

Expert Comment

by:gencross
ID: 7162948
When I expand the TreeView it stays at the top where the parent is even if the list of child nodes is longer than the treeview.  What properties are you setting?

Perhaps do a test and create a new treeview, don't set any properties and populate it.  This should do what you want.  Also, what version of the treeview control are you using?
0
 

Author Comment

by:jackjeckyl
ID: 7164878
I haven't changed any properties other than LabelEdit and SingleSel.  I started with ADO 2.5, but switched to 2.6 and it doesn't make a difference.
0
 
LVL 4

Expert Comment

by:gencross
ID: 7164880
Please post the code you are using.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jackjeckyl
ID: 7165088
Private Sub LoadDates(ByVal table_node As Node)
Dim rs As ADODB.Recordset
Dim sSQL As String
Dim i As Integer
Dim record_text As String
Dim record_node As Node

'Do nothing if the table's records are already loaded.
If table_node.Children > 0 Then Exit Sub

lblStatus.Caption = "Populating Dates"

Set rs = New ADODB.Recordset

i = 0
Do Until vJobInfo(i).sJob = Left$(table_node, Len(vJobInfo(i).sJob))
    i = i + 1
Loop

sSQL = "Select distinct(processingdate) as date from batch where lockboxid in (" & vJobInfo(i).sCustIDs & _
    ") order by processingdate desc "

With rs
    .Open sSQL, connProduction, adOpenStatic, adLockReadOnly
    Do Until rs.EOF
        table_node.Image = 2

        ' Add the record node
        Set record_node = TreeView1.Nodes.Add(table_node, tvwChild, , !Date)
        record_node.Tag = "Date"
        'record_node.EnsureVisible
        record_node.Visible = True

        ' Get the next record
        rs.MoveNext
       
        If .EOF Then
            ProgressBar1.Value = ProgressBar1.Max
        Else
            ProgressBar1.Value = (.AbsolutePosition / .RecordCount) * ProgressBar1.Max
        End If
       
    Loop
End With
   
rs.Close
Set rs = Nothing
ProgressBar1.Value = 0
lblStatus.Caption = "Select Date"

End Sub
0
 

Author Comment

by:jackjeckyl
ID: 7165090
Private Sub LoadDates(ByVal table_node As Node)
Dim rs As ADODB.Recordset
Dim sSQL As String
Dim i As Integer
Dim record_text As String
Dim record_node As Node

'Do nothing if the table's records are already loaded.
If table_node.Children > 0 Then Exit Sub

lblStatus.Caption = "Populating Dates"

Set rs = New ADODB.Recordset

i = 0
Do Until vJobInfo(i).sJob = Left$(table_node, Len(vJobInfo(i).sJob))
    i = i + 1
Loop

sSQL = "Select distinct(processingdate) as date from batch where lockboxid in (" & vJobInfo(i).sCustIDs & _
    ") order by processingdate desc "

With rs
    .Open sSQL, connProduction, adOpenStatic, adLockReadOnly
    Do Until rs.EOF
        table_node.Image = 2

        ' Add the record node
        Set record_node = TreeView1.Nodes.Add(table_node, tvwChild, , !Date)
        record_node.Tag = "Date"
        'record_node.EnsureVisible
        record_node.Visible = True

        ' Get the next record
        rs.MoveNext
       
        If .EOF Then
            ProgressBar1.Value = ProgressBar1.Max
        Else
            ProgressBar1.Value = (.AbsolutePosition / .RecordCount) * ProgressBar1.Max
        End If
       
    Loop
End With
   
rs.Close
Set rs = Nothing
ProgressBar1.Value = 0
lblStatus.Caption = "Select Date"

End Sub
0
 
LVL 4

Expert Comment

by:gencross
ID: 7165120
Try commenting the record_node.Visible = True line if you haven't already.


0
 

Author Comment

by:jackjeckyl
ID: 7165487
Yeah, I have.  I tried to switch between ensurevisible to visible.  Still don't work.
0
 

Accepted Solution

by:
Jgould earned 0 total points
ID: 7369154
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question