Hola Compañeros!!!
Resulta que hago una consulta en un TreeView y aplico la propiedad expanded... para expandir el nodo del TreeView que tiene datos de la siguiente manera:
Código vb:
Ver originalWith TreeView
.Nodes.Clear
.Nodes.Add , , "Paciente", "Paciente"
.Nodes.Add , , "Fertilidad", "Fertilidad"
cmd2.CommandText = "select historia,fecha from fertilidad where historia ='" & numhis & "'"
Set rst = cmd2.Execute
If rst.RecordCount > 0 Then
For X = 1 To rst.RecordCount
.Nodes.Add "Fertilidad", tvwChild, , rst.Fields(1).Value
.Nodes(X).Expanded = True
rst.MoveNext
Next X
End If
.Nodes.Add , , "Ginecologia", "Ginecologia"
cmd2.CommandText = "select historia,fecha from ginecologia where historia ='" & numhis & "'"
Set rst = cmd2.Execute
If rst.RecordCount > 0 Then
For X = 1 To rst.RecordCount
.Nodes.Add "Ginecologia", tvwChild, , rst.Fields(1).Value
.Nodes(X).Expanded = True
rst.MoveNext
Next X
End If
.Nodes.Add , , "Obstetricia", "Obstetricia"
cmd2.CommandText = "select historia,fecha from obstetricia where historia ='" & numhis & "'"
Set rst = cmd2.Execute
If rst.RecordCount > 0 Then
For X = 1 To rst.RecordCount
.Nodes.Add "Obstetricia", tvwChild, , rst.Fields(1).Value
.Nodes(X).Expanded = True
rst.MoveNext
Next X
End If
.Nodes.Add , , "Urologia", "Urologia"
cmd2.CommandText = "select historia,fecha from urologia where historia ='" & numhis & "'"
Set rst = cmd2.Execute
If rst.RecordCount > 0 Then
For X = 1 To rst.RecordCount
.Nodes.Add "Urologia", tvwChild, , rst.Fields(1).Value
.Nodes(X).Expanded = True
rst.MoveNext
Next X
End If
.Nodes.Add , , "Laboratorios", "Laboratorios"
' where CI='" & cedulai & "' or CI='" & Format(cedulai, "#") & "'"
If cedulai <> "" Then
cmd3.CommandText = "SELECT Examenes.Fecha" _
& " FROM Examenes INNER JOIN Paciente ON Examenes.IdPaciente = Paciente.IdPaciente INNER JOIN ItemSeccion ON Examenes.IdExamen = ItemSeccion.IdExamen" _
& " WHERE (Examenes.Resultado IS NOT NULL) and (CI='" & cedulai & "' or CI='" & Format(cedulai, "#") & "') group by Examenes.fecha "
Set rst = cmd3.Execute
If rst.RecordCount > 0 Then
For X = 1 To rst.RecordCount
.Nodes.Add "Laboratorios", tvwChild, , rst.Fields(0).Value
.Nodes(X).Expanded = True
rst.MoveNext
Next X
End If
End If
End With
End Sub
Pero en ocasiones... el nodo no abre a pesar de que tiene datos... Alguien tiene una respuesta para esta situación...
Muchas Gracias por leerme y full éxito