Access - TreeView

 
Vista:

TreeView

Publicado por Javi (22 intervenciones) el 21/07/2003 19:36:13
Hola a tod@s:

Estuve mirando en el Foro y no vi ninguna solucion para crear un TreeView.
Asi que he estado investigando como desarrollar un TreeView y he llegado hasta aqui (por si le sirve a alguien):

With TreeView0
.Sorted = True
Set Nodos = .Nodes.Add()
.LabelEdit = False
' .LineStyle = tvwRootLines
End With
With Nodos ' Agregar el primer nodo.
.Text = "Padre1"
.Tag = "1"
End With
With TreeView0
.Sorted = True
Set Nodos = .Nodes.Add()
.LabelEdit = False
.LineStyle = tvwRootLines
End With
With Nodos ' Agregar el segundo nodo.
.Text = "Padre2"
.Tag = "2"
End With
With TreeView0
.Sorted = True
Set Nodos = .Nodes.Add()
.LabelEdit = False
.LineStyle = tvwRootLines
End With
With Nodos ' Agregar el tercer nodo.
.Text = "Padre3"
.Tag = "3"
End With
Set Nodos = TreeView0.Nodes.Add(1, tvwChild, , "Hijo1")
Set Nodos = TreeView0.Nodes.Add(1, tvwChild, , "Hijo2")

Set Nodos = TreeView0.Nodes.Add(3, tvwChild, , "Hijo3")
Set Nodos = TreeView0.Nodes.Add(3, tvwChild, , "Hijo4")

Esto funciona correctamente. Muestra un arbol jerarquico tipo Producto... Subproducto.
Pero lo que quiero ademas, es marcar uno de esos valores como seleccionado inicialmente y ademas si me selecionan otro poder identificarlo.

¿Alguien ha hecho algo parecido?
Muchas gracias anticipadas.

Salu2.
Javi
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 14
Ha disminuido su posición en 29 puestos en Access (en relación al último mes)
Gráfica de Access

RE:TreeView

Publicado por Yamil Bracho (112 intervenciones) el 22/07/2003 16:27:37
Me he tomado la libertad de modificar algo tu codigo y agregarle el soporte a las dudas que tenias. He aqui el codigo:

Option Compare Database
Option Explicit

Private Sub CtrlActiveX0_Click()
Dim oTree As MSComctlLib.TreeView
Dim nodo As MSComctlLib.Node

Set oTree = Me.CtrlActiveX0.Object
Set oNodo = oTree.SelectedItem

If Not oNodo Is Nothing Then
MsgBox "Se ha selecicionado el Nodo " & oNodo.Key
End If

End Sub

Private Sub Form_Load()
Dim oTree As MSComctlLib.TreeView

Set oTree = Me.CtrlActiveX0.Object
With oTree
.Sorted = True
.LabelEdit = False
.LineStyle = tvwRootLines

.Nodes.Add Key:="Padre1", Text:="Padre1"
.Nodes.Add Key:="Padre2", Text:="Padre2"
.Nodes.Add Key:="Padre3", Text:="Padre3"

.Nodes.Add "Padre1", tvwChild, , "Hijo1"
.Nodes.Add "Padre1", tvwChild, , "Hijo2"

.Nodes.Add "Padre3", tvwChild, , "Hijo3"
.Nodes.Add "Padre3", tvwChild, , "Hijo4"
End With

' Por defecto se selecciona el primer nodo, asi que
' para efectos de demo seleccionaremos el nodo Padre 3
' como el seleccionado al arrancar el formulario
Set oTree.SelectedItem = oTree.Nodes("Padre3")

End Sub

Espero esto te ayude y saludos

.

Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:TreeView

Publicado por JAvi (22 intervenciones) el 22/07/2003 17:23:54
YAmil,
Muchisimas gracias, era exactamente lo que estaba intentando hacer. Habia visto otros ejemplos pero me obligaba a definir una ListView para identificar el valor selecionado y queria introducir otro control más
Mil Gracias y saludos a todo el foro.
Javi.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar