Solved

Treeview question - easy!

Posted on 2002-07-18
10
120 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

786 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