Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have these 2 user controls that have coding in them that i need to run on a button click on the main form. I have the user controls load on a button click and here is that code:

SQL
If Me.Outlookbar.SelectedPage.Equals(Me.Machine_Tab) Then
    Dim Obj1 As New Machine_Info_Alerts
    Obj1.Dock = DockStyle.Fill
    Me.Panel1.Controls.Clear()
    Me.Panel1.Controls.Add(Obj1)

    Me.Machine_Name_Textbox_Header.Enabled = True
End If


now on the main form i have a button click that once it copies the files to my machine it reads data from a file and then displays it in the usercontrol. When I run the code it copies the files but it wont show the data in the user control. I have tested the code by creating a refresh button on the user control and it reads the data so i know that works but i dont understand why i can get the main form and the usercontrol to work together.

here is the code i m using on the button click:

note: the user control name is CAE and the main form is called application. I know there are some general names here but i want to get the code working before i go naming everything.

VB
Private Sub CAE_Quert_Aservice_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CAE_Quert_Aservice_Button.Click

        If strComputer = "" Then
            strComputer = "127.0.0.1"
        End If
        CAE.CAE_Listview.Items.Clear()
        '----------------------------------------------------
        Dim FileToDelete As String

        FileToDelete = "C:\Temp\Aservice.EDM"

        If System.IO.File.Exists(FileToDelete) = True Then
            System.IO.File.Delete(FileToDelete)
        End If
        '------------------------------------------------------
        Dim copyTo As String = "C:\temp\ASERVICE.EDM"
        Dim copyFrom As String = "\\" & strComputer & "\C$\Progra~2\Hewlett-Packard\HPCA\Agent\Lib\SYSTEM\RADIA\SOFTSRVC\ASERVICE.EDM"
        File.Copy(copyFrom, copyTo, True)
        '----------------------.--------------------------------

        objsh = CreateObject("WScript.Shell")

        Dim strObject As String = "C:\Temp\ASERVICE.EDM"

        Dim process = GetObject("winmgmts://./root/novadigm:NVD_Agent")
        Dim method = process.Methods_("GetValue")
        Dim inParameters = method.inParameters.SpawnInstance_()
        inParameters.Path = strObject
        Dim outParameters = process.ExecMethod_("NumberOfInstances", inParameters)
        Dim StrHeaps = (outParameters.InstanceCount)
        CAE.CAE_Heap_Count.Text = StrHeaps
        For i = 0 To StrHeaps Step 1

            inParameters.Index = i

            inParameters.Property = "ZOBJNAME"
            outParameters = process.ExecMethod_("GetValue", inParameters)
            Dim Value2 As String = outParameters.Value

            inParameters.Property = "ZAVIS"
            outParameters = process.ExecMethod_("GetValue", inParameters)
            Dim Value3 As String = outParameters.Value

            inParameters.Property = "ZSVCCSTA"
            outParameters = process.ExecMethod_("GetValue", inParameters)
            Dim Value4 As String = outParameters.Value

            inParameters.Property = "NAME"
            outParameters = process.ExecMethod_("GetValue", inParameters)
            Dim Value5 As String = outParameters.Value

            inParameters.Property = "INSTDATE"
            outParameters = process.ExecMethod_("GetValue", inParameters)
            Dim value6 As String = outParameters.Value

            inParameters.Property = "ZVERIFY"
            outParameters = process.ExecMethod_("GetValue", inParameters)
            Dim value8 As String = outParameters.Value

            'Date
            Dim str As String
            Dim strArr() As String
            Dim count As Integer
            Dim value7 As String
            str = value6
            strArr = str.Split("T")
            For count = 0 To strArr.Length - 2
                value7 = (strArr(count))
            Next

            Dim value1 = CAE.CAE_Listview.Items.Count
            Dim item As New ListViewItem(value1)
            item.SubItems.Add(Value2)
            item.SubItems.Add(Value3)
            item.SubItems.Add(Value4)
            item.SubItems.Add(Value5)
            item.SubItems.Add(value7)
            item.SubItems.Add(value8)
            CAE.CAE_Listview.Items.Add(item)
            CAE.CAE_Listview.FullRowSelect = True

        Next
        CAE.CAE_Listview.Items(CAE.CAE_Listview.Items.Count - 1).Remove()
    End Sub
Posted

1 solution

Epic Fail... I found that the button was missing the handler for the click event.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900