vb.net UserControl帮助

编程入门 行业动态 更新时间:2024-10-09 21:25:20
本文介绍了vb UserControl帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有这两个具有编码的用户控件,我需要在主窗体上单击按钮后运行.我在按钮上单击时加载了用户控件,这是该代码:

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:

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

现在在主窗体上,我单击按钮,一旦将文件复制到我的机器上,它将从文件中读取数据,然后将其显示在用户控件中.当我运行代码时,它会复制文件,但不会在用户控件中显示数据.我已经通过在用户控件上创建一个刷新按钮来测试代码,并且它读取数据,因此我知道该方法有效,但是我不明白为什么我可以使主窗体和用户控件一起工作. 这是我在单击按钮时使用的代码: 注意:用户控件名称是CAE,主要形式称为应用程序.我知道这里有一些通用名称,但是我想在命名所有内容之前使代码正常工作.

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.

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

推荐答案

\ Progra〜2 \ Hewlett-Packard \ HPCA \ Agent \ Lib \ SYSTEM \ RADIA \ SOFTSRVC \ ASERVICE.EDM" File.Copy(copyFrom,copyTo,真) ' ----------------------.-- ------------------------------ objsh = CreateObject(" WScript.Shell" ) Dim strObject As 字符串 = " C:\ Temp \ ASERVICE.EDM" Dim 进程= GetObject(" winmgmts://./root/novadigm:NVD_Agent") Dim 方法= process.Methods _(" GetValue" ) Dim inParameters = method.inParameters.SpawnInstance_() inParameters.Path = strObject Dim outParameters = process.ExecMethod _(" NumberOfInstances" ,inParameter) Dim StrHeaps =(outParameters.InstanceCount) CAE.CAE_Heap_Count.Text = StrHeaps 对于 i = 0 >到 StrHeaps 步骤 1 inParameters.Index = i inParameters.属性 = " ZOBJNAME" outParameters = process.ExecMethod _(" GetValue" ,inParameters) Dim Value2 As String = outParameters.Value inParameters.属性 = " ZAVIS" outParameters = process.ExecMethod _(" GetValue" ,inParameters) Dim Value3 As String = outParameters.Value inParameters.属性 = " ZSVCCSTA" outParameters = process.ExecMethod _(" GetValue" ,inParameters) Dim Value4 As String = outParameters.Value inParameters.属性 = " NAME" outParameters = process.ExecMethod _(" GetValue" ,inParameters) Dim Value5 As String = outParameters.Value inParameters.属性 = " INSTDATE" outParameters = process.ExecMethod _(" GetValue" ,inParameters) Dim value6 As String = outParameters.Value inParameters.属性 = " ZVERIFY" outParameters = process.ExecMethod _(" GetValue" ,inParameters) Dim value8 As String = outParameters.Value ' 日期 Dim str As 字符串 Dim strArr() As 字符串 Dim 计数 As 整数 Dim value7 As 字符串 str =值6 strArr = str.Split(" T" ) For 计数= 0 To strArr.Length - 2 值7 =(strArr(count)) 下一步 Dim value1 = CAE.CAE_Listview.Items.Count Dim 项 As 新建 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(项目) CAE.CAE_Listview.FullRowSelect = 真 下一步 CAE.CAE_Listview.Items(CAE.CAE_Listview.Items.Count- 1 ).Remove() 结束 子 \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

史诗失败...我发现该按钮缺少click事件的处理程序. Epic Fail... I found that the button was missing the handler for the click event.

更多推荐

vb.net UserControl帮助

本文发布于:2023-11-11 08:46:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577931.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:vb   net   UserControl

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!