Solved

Treeview question - easy!

Posted on 2002-07-18
10
119 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
Comment Utility
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
Comment Utility
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
Comment Utility
Please post the code you are using.
0
 

Author Comment

by:jackjeckyl
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:jackjeckyl
Comment Utility
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
Comment Utility
Try commenting the record_node.Visible = True line if you haven't already.


0
 

Author Comment

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

Accepted Solution

by:
Jgould earned 0 total points
Comment Utility
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now