PDA

View Full Version : Treeview shifts position on multipage form



DCritelli
03-11-2008, 12:55 PM
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

lucas
03-11-2008, 05:16 PM
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.

DCritelli
03-12-2008, 07:09 AM
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.

stapuff
03-12-2008, 07:28 AM
D -

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

Kurt

DCritelli
03-12-2008, 07:31 AM
Yes, it's a treeview, within a multipage, within a userform. If that makes sense..

stapuff
03-12-2008, 07:34 AM
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

lucas
03-12-2008, 07:40 AM
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......

DCritelli
03-12-2008, 07:42 AM
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.

DCritelli
03-12-2008, 07:43 AM
My code is not much different from what's above.

stapuff
03-12-2008, 07:52 AM
D -

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

Thanks,

Kurt

DCritelli
03-12-2008, 07:54 AM
I'll cut out some stuff and post the project in a few minutes. So you can see everything.

DCritelli
03-12-2008, 08:13 AM
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.

DCritelli
03-12-2008, 08:14 AM
The forms are in the 9701Illustrations sheet.

DCritelli
03-13-2008, 08:46 AM
Any ideas why this might still be happening? I wasn't able to solve the problem with the code above.

lucas
03-13-2008, 09:49 AM
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.

DCritelli
03-13-2008, 10:06 AM
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.