Consulting

Results 1 to 16 of 16

Thread: Treeview shifts position on multipage form

  1. #1

    Treeview shifts position on multipage form

    Hello,

    I've got a hopefully simple question. I have a multipage control that has a treeview on one of the tabs. The treeview pulls it's nodes off of a spreadsheet when you make a selection from a dropdown box. The problem I'm having is; if the form is loaded on any tab other than the one the treeview is on, the treeview shifts up to the top of the multipage. If I click off/on to the tab the treeview moves back to where it should be. If there form is loaded on the tab with the treeview from the start there is no problem.

    I tried repainting the form when the tabs change with me.repaint in the multipage change event but that does nothing. My searching around in other forums hasn't turned anything up either. I'm sure i'm just doing something wrong. I would attach an example but that would involve 2 really big spreadsheets, so I can't.

    If somebody could suggest something simple I would appreciate it.

    Thanks,

    DCritelli

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    if the form is loaded on any tab other than the one the treeview is on, the treeview shifts up to the top of the multipage.
    Any problem forcing it to load on that tab each time? As a workaround at least.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Yeah, I thought about that but there is a second tab with an identical treeview. It doesn't have the same problem but I have not put any code behind it yet either. I'm assuming once it loads like the other one I will have the same problem.

    This has happened to me before and I could never find an answer.

  4. #4
    D -

    Can I ask a stupid question - is this on a Userform?

    Kurt

  5. #5
    Yes, it's a treeview, within a multipage, within a userform. If that makes sense..

  6. #6
    I have used the treeview on a multipage userform see and modify the code as desired. I did not have a problem like you do. I had 3 treeviews.

    Private Sub fill_in_treeview()
    'Purpose: Populate the treeview control
        Dim ws As Worksheet
        Dim cl As Range
        Dim sParentWH As String
        Dim sParentPart As String
        Dim sChildPart As String
        Dim a As String
        Dim u As MultiPage
        Set u = MultiPage1
        UserForm2.MultiPage1.Value = 2
        a = UserForm2.MultiPage1(0).TextBox2.Value
        UserForm2.MultiPage1(2).TextBox20.Value = a
    On Error GoTo error1
    With Me
            .TreeView1.Sorted = False
            .TreeView1.LineStyle = tvwRootLines
        With Me.TreeView1.Nodes
            'Clear TreeView control
            .Clear
            For Each cl In Worksheets("Prod_Struct").Range("A3:A20000")
         'Add parent WH if necessary
        If cl.Value = sParentWH Then
             'same parent, ignore
        Else
            sParentWH = cl.Value
            .Add , sParentWH, sParentWH, sParentWH
                End If
                'Add parent Part # if necessary
                If cl.Offset(0, 1).Value = sParentPart Then
                    'same parent, ignore
                Else
                    sParentPart = cl.Offset(0, 1).Value
                    .Add relative:=sParentWH, _
                            relationship:=tvwChild, _
                            Key:=sParentWH & "-" & sParentPart, _
                            Text:=sParentPart
                End If
                'Add child Part and quantity
                If cl.Offset(0, 3).Value = sChildPart Then
                    'same child, ignore
                Else
                    sChildPart = cl.Offset(0, 3).Value
                    .Add relative:=sParentWH & "-" & sParentPart, _
                            relationship:=tvwChild, _
                            Key:=sParentWH & "-" & sParentPart & "-" & sChildPart, _
                            Text:=sChildPart
                    .Add relative:=sParentWH & "-" & sParentPart & "-" & sChildPart, _
                            relationship:=tvwChild, _
                            Key:=sParentWH & "-" & sParentPart & "-" & sChildPart & "-Quantity", _
                            Text:="Quantity=  " & cl.Offset(0, 4).Value
                            End If
            Next cl
        End With
      End With
    error1:
    End Sub

  7. #7
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    If stapuff's idea doesn't work maybe you can strip your workbook down to just the problem......zip it up and post it....it would help a lot to see the problem......
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  8. #8
    I also have text/combo boxes on the same tab as the problem treeview. The boxes are hidden when it first loads. Is it possible that manipulating the boxes could cause something like that to happen? I don't see why, but I can't seem to find any clue as to why this is going on.

  9. #9
    My code is not much different from what's above.

  10. #10
    D -

    I also have a listbox & textbox on my UF Multipage Treeview. Could you post the code?

    Thanks,

    Kurt

  11. #11
    I'll cut out some stuff and post the project in a few minutes. So you can see everything.

  12. #12

    example

    Here is the example. The fourth tab is the treeview that loads from the spreadsheet. You have to choose from the dropdown box when the form loads or everything is disabled.

  13. #13
    The forms are in the 9701Illustrations sheet.

  14. #14
    Any ideas why this might still be happening? I wasn't able to solve the problem with the code above.

  15. #15
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    DCitelli,
    I have been looking at this for a half an hour or so and I see your problem but I can't explain it either.......would it be possible to set the treeview control's top property at userform initialize? Untried....

    I didn't want you to think that no one was willing to take a look at this with you.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  16. #16
    Quote Originally Posted by lucas
    DCitelli,
    I have been looking at this for a half an hour or so and I see your problem but I can't explain it either.......would it be possible to set the treeview control's top property at userform initialize? Untried....

    I didn't want you to think that no one was willing to take a look at this with you.
    No problem at all, I realize all the time spent here is voluntary. I'm not expecting answers the moment I post something. I just didn't want the post getting buried.

    Setting the top property didn't not solve the problem. Thanks again for your time.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •