【发布时间】:2016-01-22 07:00:09
【问题描述】:
我确实有一个日常监控项目,但在从我的文本框中获取文本时遇到问题,我的文本框在我的用户控件中。
情况是,如果我点击显示按钮,userControl.vb 将在我的面板中被调用,我没有问题将 userControl.vb 放到我的面板上,如果我点击保存按钮,它将检查是否所有在保存数据之前填写字段。我会正常保存,不会检查加载 userControl.vb 的面板
这是我的 sn-p 项目树:
DXApplication
|_My Porject
|_User Control <folder>
|_userControl.vb <user control form>
|_frmMainActivity <winForm>
这是我在面板中加载 userControl 的代码
Friend ctrlUser As UserControl
ctrlUser = New userControlx
ctrlUser.Dock = DockStyle.Top
pnlActivity.Controls.Clear()
pnlActivity.Controls.Add(ctrlUser)
这里是从另一个 sub 从 userControl 调用文本框的代码,以检查代码是否可以获取文本。
*edited the userControl should be userControlx*
Dim uc As New userControlx
Msgbox(uc.txtLatitude.text)
当我按下触发按钮以显示我在文本框中输入的文本时,我将返回带有空字符串的 msgbox。
有什么建议吗?我在调用文本框的值时哪里出错了?
我尝试过使用:
Dim uc As New userControlx
uc.txtLongitude.text = "Test Text"
msgbox(ux.txtLongitude.txt)
它将返回 测试文本,但在我的 UI 中,加载的文本框是空的。
【问题讨论】:
-
uc 正在创建用户控件的新实例。您不应该尝试检查 ctrlUser 中的值吗?
标签: vb.net user-controls