de hecho si he generado un codigo y es este :
Dim nodo As TreeNode
Dim nodoDeps As TreeNode
Dim nodoDirs As TreeNode
Dim nodoSubs As TreeNode
Dim nodoOfs As TreeNode
Private Sub CargarNodos()
'conexion
Dim Cnn As New MySqlConnection("Database=SIARH;Data Source=localhost;User Id=root;Password=wolfman")
'cadenas sql
Dim SQLStrDirGral As String = "Select ID, DireccionGral, Sigs from TAuxCTDireccionGral"
Dim SQLStrDirecc As String = "Select ID, DireccionGral, Direccion, Sigs from TAuxCTDireccion"
Dim SQLStrSubdD As String = "Select ID, Direccion, SubDireccionCoordinacion, Sigs from TAuxCTSubDirCoord"
Dim SQLStrDepto As String = "Select ID, SubCoord, Departamento, Sigs from TAuxCTDeptos"
Dim SQLStrOfna As String = "Select ID, Departamento, Oficina, Sigs from TAuxCTOficinas"
'variables de busqueda
'Adaptadores
Dim daDirGral As New MySqlDataAdapter
Dim daDir As New MySqlDataAdapter
Dim daSubDir As New MySqlDataAdapter
Dim daDeptos As New MySqlDataAdapter
Dim daOfnas As New MySqlDataAdapter
'El dataset
Dim dsPlantilla As DataSet
'vista de datos
Dim dvDir As DataView
Dim dvSubdir As DataView
Dim dvDepto As DataView
Dim dvOfnal As DataView
dsPlantilla = New DataSet
SQLStrDirGral = "Select ID, DireccionGral, Sigs from TAuxCTDireccionGral"
daDirGral = New MySqlDataAdapter(SQLStrDirGral, Cnn)
daDirGral.Fill(dsPlantilla, "TAuxCTDireccionGral")
SQLStrDirecc = "Select ID, DireccionGral, Direccion, Sigs from TAuxCTDireccion"
daDir = New MySqlDataAdapter(SQLStrDirecc, Cnn)
daDir.Fill(dsPlantilla, "TAuxCTDireccion")
SQLStrSubdD = "Select ID, Direccion, SubDireccionCoordinacion, Sigs from TAuxCTSubDirCoord"
daSubDir = New MySqlDataAdapter(SQLStrSubdD, Cnn)
daSubDir.Fill(dsPlantilla, "TAuxCTSubDirCoord")
SQLStrDepto = "Select ID, SubCoord, Departamento, Sigs from TAuxCTDeptos"
daDeptos = New MySqlDataAdapter(SQLStrDepto, Cnn)
daDeptos.Fill(dsPlantilla, "TAuxCTDeptos")
SQLStrOfna = "Select ID, Departamento, Oficina, Sigs from TAuxCTOficinas"
daOfnas = New MySqlDataAdapter(SQLStrOfna, Cnn)
daOfnas.Fill(dsPlantilla, "TAuxCTOficinas")
'filas de datos se almacenan en esta categoria
Dim drDir As DataTable
Dim drSubDir As DataTable
Dim drDeptos As DataTable
Dim drOfnas As DataTable
Dim Regs As DataRow
'cargo las tablas que requiero
drDir = dsPlantilla.Tables("TAuxCTDireccion")
drSubDir = dsPlantilla.Tables("TAuxCTSubDirCoord")
drDeptos = dsPlantilla.Tables("TAuxCTDeptos")
drOfnas = dsPlantilla.Tables("TAuxCTOficinas")
dvDir = drDir.DefaultView
dvSubdir = drSubDir.DefaultView
dvDepto = drDeptos.DefaultView
dvOfnal = drOfnas.DefaultView
'primer nivel del Nodo principal
TreeView1.Nodes.Clear()
TreeView1.Nodes.Add("DIRECCION GENERAL")
' deshabilita la actualización en pantalla del control TreeView
TreeView1.BeginUpdate()
Dim i As Integer
Dim a As Integer
Dim aa As Integer
Dim b As Integer
Dim bb As Integer
For Each Regs In drDir.Rows
i = 0
' agrego el nodo en el segundo nivel
TreeView1.Nodes(i).Nodes.Add(Trim(Regs("Direccion")))
' realizo un filtro dentro de la vista
dvSubdir.RowFilter = "Direccion = " & Regs("id")
' ciclo para recorrer la vista previamente filtrada
aa = 0
For a = 0 To dvSubdir.Count - 1
' agrego el nodo en el tercer nivel
'aqui es en donde manda el error
TreeView1.Nodes(i).Nodes(aa).Nodes.Add(Trim(dvSubdir.Item(a).Row("SubDireccionCoordinacion")))
Specified argument was out of the range of valid values.
Parameter name: index
' realizo un filtro dentro de la vista
dvDepto.RowFilter = "SubCoord = " & Regs("id")
bb = 0
For b = 0 To dvDepto.Count - 1
TreeView1.Nodes(i).Nodes(a).Nodes(bb).Nodes.Add(Trim(dvDepto.Item(b).Row("Departamento")))
Next
Next
i = i + 1
Next
' habilita la actualización en pantalla del control TreeView
TreeView1.Nodes(i).ExpandAll()
' habilita la actualización en pantalla del control TreeView
TreeView1.EndUpdate()
End Sub
Dim nodo As TreeNode
Dim nodoDeps As TreeNode
Dim nodoDirs As TreeNode
Dim nodoSubs As TreeNode
Dim nodoOfs As TreeNode
Private Sub CargarNodos()
'conexion
Dim Cnn As New MySqlConnection("Database=SIARH;Data Source=localhost;User Id=root;Password=wolfman")
'cadenas sql
Dim SQLStrDirGral As String = "Select ID, DireccionGral, Sigs from TAuxCTDireccionGral"
Dim SQLStrDirecc As String = "Select ID, DireccionGral, Direccion, Sigs from TAuxCTDireccion"
Dim SQLStrSubdD As String = "Select ID, Direccion, SubDireccionCoordinacion, Sigs from TAuxCTSubDirCoord"
Dim SQLStrDepto As String = "Select ID, SubCoord, Departamento, Sigs from TAuxCTDeptos"
Dim SQLStrOfna As String = "Select ID, Departamento, Oficina, Sigs from TAuxCTOficinas"
'variables de busqueda
'Adaptadores
Dim daDirGral As New MySqlDataAdapter
Dim daDir As New MySqlDataAdapter
Dim daSubDir As New MySqlDataAdapter
Dim daDeptos As New MySqlDataAdapter
Dim daOfnas As New MySqlDataAdapter
'El dataset
Dim dsPlantilla As DataSet
'vista de datos
Dim dvDir As DataView
Dim dvSubdir As DataView
Dim dvDepto As DataView
Dim dvOfnal As DataView
dsPlantilla = New DataSet
SQLStrDirGral = "Select ID, DireccionGral, Sigs from TAuxCTDireccionGral"
daDirGral = New MySqlDataAdapter(SQLStrDirGral, Cnn)
daDirGral.Fill(dsPlantilla, "TAuxCTDireccionGral")
SQLStrDirecc = "Select ID, DireccionGral, Direccion, Sigs from TAuxCTDireccion"
daDir = New MySqlDataAdapter(SQLStrDirecc, Cnn)
daDir.Fill(dsPlantilla, "TAuxCTDireccion")
SQLStrSubdD = "Select ID, Direccion, SubDireccionCoordinacion, Sigs from TAuxCTSubDirCoord"
daSubDir = New MySqlDataAdapter(SQLStrSubdD, Cnn)
daSubDir.Fill(dsPlantilla, "TAuxCTSubDirCoord")
SQLStrDepto = "Select ID, SubCoord, Departamento, Sigs from TAuxCTDeptos"
daDeptos = New MySqlDataAdapter(SQLStrDepto, Cnn)
daDeptos.Fill(dsPlantilla, "TAuxCTDeptos")
SQLStrOfna = "Select ID, Departamento, Oficina, Sigs from TAuxCTOficinas"
daOfnas = New MySqlDataAdapter(SQLStrOfna, Cnn)
daOfnas.Fill(dsPlantilla, "TAuxCTOficinas")
'filas de datos se almacenan en esta categoria
Dim drDir As DataTable
Dim drSubDir As DataTable
Dim drDeptos As DataTable
Dim drOfnas As DataTable
Dim Regs As DataRow
'cargo las tablas que requiero
drDir = dsPlantilla.Tables("TAuxCTDireccion")
drSubDir = dsPlantilla.Tables("TAuxCTSubDirCoord")
drDeptos = dsPlantilla.Tables("TAuxCTDeptos")
drOfnas = dsPlantilla.Tables("TAuxCTOficinas")
dvDir = drDir.DefaultView
dvSubdir = drSubDir.DefaultView
dvDepto = drDeptos.DefaultView
dvOfnal = drOfnas.DefaultView
'primer nivel del Nodo principal
TreeView1.Nodes.Clear()
TreeView1.Nodes.Add("DIRECCION GENERAL")
' deshabilita la actualización en pantalla del control TreeView
TreeView1.BeginUpdate()
Dim i As Integer
Dim a As Integer
Dim aa As Integer
Dim b As Integer
Dim bb As Integer
For Each Regs In drDir.Rows
i = 0
' agrego el nodo en el segundo nivel
TreeView1.Nodes(i).Nodes.Add(Trim(Regs("Direccion")))
' realizo un filtro dentro de la vista
dvSubdir.RowFilter = "Direccion = " & Regs("id")
' ciclo para recorrer la vista previamente filtrada
aa = 0
For a = 0 To dvSubdir.Count - 1
' agrego el nodo en el tercer nivel
'aqui es en donde manda el error
TreeView1.Nodes(i).Nodes(aa).Nodes.Add(Trim(dvSubdir.Item(a).Row("SubDireccionCoordinacion")))
Specified argument was out of the range of valid values.
Parameter name: index
' realizo un filtro dentro de la vista
dvDepto.RowFilter = "SubCoord = " & Regs("id")
bb = 0
For b = 0 To dvDepto.Count - 1
TreeView1.Nodes(i).Nodes(a).Nodes(bb).Nodes.Add(Trim(dvDepto.Item(b).Row("Departamento")))
Next
Next
i = i + 1
Next
' habilita la actualización en pantalla del control TreeView
TreeView1.Nodes(i).ExpandAll()
' habilita la actualización en pantalla del control TreeView
TreeView1.EndUpdate()
End Sub