How to update parent Form Treeview or other control?


Author
Message
Amy Tai
Amy Tai
StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)
Group: Forum Members
Posts: 5, Visits: 16
Dear Sir/Madam

        I have a problem about how to refresh the parent form treview data. In my program, When SQL table updated, In my Bo the ServerData changed Event received the notification. So I call  FrmMain.LoadMsg() to refresh the treeview data in Bo ServerDataChanged Event. I found the FrmMain.LoadMsg is running but the FrmMain's treeview not refresh. please told to me how to apply this function. (I using VB.net) , Thanks a lot.

    Private Sub SystemMsgBO_ServerDataChanged(ByVal e As System.Data.SqlClient.SqlNotificationEventArgs) Handles Me.ServerDataChanged

          MsgBox(e.Info.ToString() & ControlChars.CrLf & e.Source.ToString() & ControlChars.CrLf & e.Type.ToString())

           FrmMain.LoadMsg()

End Sub

Reply
Amy Tai
Amy Tai
StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)StrataFrame Beginner (5 reputation)
Group: Forum Members
Posts: 5, Visits: 16
Hi Edhy,

      Thank you for you help! the code for  the LoadMsg and also the code for the BO event  as bellow. I think the main problem is how to refresh the parentform control through chilform. If the FrmMain Activated, I call the LoadMsg on the FrmMain treeview data refreshed.

    Public Sub SystemMsgBO_ServerDataChanged(ByVal e As System.Data.SqlClient.SqlNotificationEventArgs) Handles Me.ServerDataChanged

        '-- Show the query information to make sure it had been executed
        MsgBox(e.Info.ToString() & ControlChars.CrLf & e.Source.ToString() & ControlChars.CrLf & e.Type.ToString())
        FrmMain.LoadMsg()
    End Sub

'the following code in FrmMain
#Region "Load MessageTree"
    Private Sub LoadMsg()

        '-- Establish Locals
        Dim loMsgNode As TreeNode

        '-- Clear the tree
        CheckedTreeView2.Nodes.Clear()

        Dim MyMsgBo As New SystemMsgTitleBO
        Dim loParentID As String
        MyMsgBo.FillDataTable("select * from SystemMessageTitle" )

        '-- Cycle through all of the parent records
        If MyMsgBo.MoveFirst() Then
            Do
                '-- Create the new root node
                loMsgNode = New TreeNode(MyMsgBo.MsgCategory)
                loParentID = MyMsgBo.MsgCategory

                '-- Load any children nodes
                LoadMsgChildNodes(loParentID, loMsgNode)
                Me.CheckedTreeView2.Nodes.Add(loMsgNode)
            Loop While MyMsgBo.MoveNext()
        End If
        '-- Expand and show the last node
        Me.CheckedTreeView2.ExpandAll()
        Me.CheckedTreeView2.SelectedNode = CheckedTreeView2.Nodes(0)
    End Sub

    Private Sub LoadMsgChildNodes(ByVal ParentID As String, ByVal ParentNode As TreeNode)
        '-- Establish Locals
        Dim loMsgNode As TreeNode

        '-- Load the child records
        Dim loChildMsgBO As New SystemMsgBO
        loChildMsgBO.FillDataTable("select * from SystemMessage where MsgCategory='" & ParentID & "' and postto='All' or postto='" & SecurityBasics.CurrentUser.UserName & "'")

        '-- Cycle through the child nodes
        If loChildMsgBO.MoveFirst() Then
            Do
                '-- Create the node
                loMsgNode = New TreeNode(loChildMsgBO.MsgDetail)
                loMsgNode.Tag = loChildMsgBO.MsgCategory

                '-- Add to parent nodes
                ParentNode.Nodes.Add(loMsgNode)

            Loop While loChildMsgBO.MoveNext()
        End If
        '-- Clean Up
        loChildMsgBO.Dispose()
    End Sub
#End Region

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search