aspvbnetnerd
Programmer
I have a treeview that I build the database when my application is loaded.
If the user adds a new customer then I have to Call refTreeview to show them the new added customer.
If I call refTreeview I want to be able to expand the menu that the user has expanded.
My Code
If the user adds a new customer then I have to Call refTreeview to show them the new added customer.
If I call refTreeview I want to be able to expand the menu that the user has expanded.
My Code
Code:
[COLOR=blue]Public Sub refTrevieew()[/color]
[code][COLOR=green]' Builds the menu for the treeview
[/color]Dim NodeParent [COLOR=blue]As[/color] TreeNode
Dim NodeChild [COLOR=blue]As[/color] TreeNode
Dim NodeChildU [COLOR=blue]As[/color] TreeNode
mDataAdapter = [COLOR=#FF00FF]New[/color] DataAdapter
[COLOR=blue]Call[/color] mDataAdapter.init(g_ConnectionString)
[COLOR=green]' TreeView
[/color][COLOR=blue]With[/color] TrViewCustomer
[COLOR=green]' Suppress repainting the TreeView until all the objects have been created.
[/color] .BeginUpdate()
.Nodes.Clear() [COLOR=green]' Clear all nodes
[/color]
[COLOR=green]'Mainmenu
[/color] NodeParent = .Nodes.Add(FormLogIn.htbLang.Item(10001).ToString) [COLOR=green]'Customer
[/color]
[COLOR=green]'2007-06-01 : Call Sp (usp_getAllCustomer)
[/color] mSqlDr = mDataAdapter.getAllCustomer()
[COLOR=blue]While[/color] mSqlDr.Read()
NodeChild = NodeParent.Nodes.Add(mSqlDr.Item("CustomerID").ToString, mSqlDr.Item("CustomerName").ToString)
NodeChild.Tag = mSqlDr.Item("CustomerID")
[COLOR=green]'Get all assignment from a customer
[/color] mSqlDrCustomerAssignment = mDataAdapter.getCustomerAssignment(CType(mSqlDr.Item("CustomerID"), [COLOR=blue]Integer[/color]))
[COLOR=blue]While[/color] mSqlDrCustomerAssignment.Read()
NodeChildU = NodeChild.Nodes.Add(mSqlDrCustomerAssignment.Item(2).ToString.PadRight(6, CType(" ", [COLOR=blue]Char[/color])) + mSqlDrCustomerAssignment.Item(4).ToString.PadLeft(2, CType("0", [COLOR=blue]Char[/color])))
.Tag = mSqlDrCustomerAssignment.Item("AssignmentID")
NodeChildU.Tag = .Tag
[COLOR=blue]End[/color] [COLOR=blue]While[/color]
[COLOR=green]'Cleaning up
[/color] mSqlDrCustomerAssignment.Close()
mSqlDrCustomerAssignment = Nothing
[COLOR=blue]End[/color] [COLOR=blue]While[/color]
.EndUpdate() [COLOR=green]' Begin repainting the TreeView.
[/color] .[COLOR=blue]Sort[/color]() [COLOR=green]' Sorting all the nodes
[/color]
[COLOR=blue]End[/color] [COLOR=blue]With[/color]
mSqlDr.Close()
mSqlDr = Nothing
mDataAdapter.dispose()
mDataAdapter = Nothing
Code:
[COLOR=blue]End Sub[/color]
Any help is appriciated