Solved

Treeview question - easy!

Posted on 2002-07-18
10
123 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: 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!

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…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

710 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