VB6中父对话框的访问控制

发布于 2024-09-13 07:04:04 字数 201 浏览 4 评论 0原文

我在 vb6 中有一个对话框,它更改其父对话框中显示的值。

x1 显示在父对话框中的 txt_c1 文本中,并且它也有一个用于文本框的 txt_1validate 函数。现在我想从子对话框中更改 txt_c1 txtbox 的值,然后调用其验证函数。但问题是 txt_c1 在子对话框中不可用。

请注意,我正在 MS VB 6.0 IDE 中使用 vb6

I have a dialog in vb6 which changes the values being displayed in its parent dialog.

The x1 is displayed in txt_c1 text in parent dialog and it has a txt_1validate function too for the text box. Now i want to change the value of txt_c1 txtbox from child dialog and then call its validate function. But the problem is that txt_c1 is not available in child dialog.

Please note that i am working in vb6 in the MS VB 6.0 IDE

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

似狗非友 2024-09-20 07:04:04

表单只是类,因此可以显式实例化(如果这样做而不是使用 VB6 中的自动实例化,您可能会发现生活更轻松),并且可以分配对表单的引用。

您可以通过在 Form 类型的子对话框 (Form1.frm) 上创建一个公共属性来解决您的问题,并将其设置为父对话框的实例,从而使您可以从子对话框访问父对话框的控件和方法。

不会是实际的、正确的代码 - 但以下内容应该可以

在调用子项的代码中工作:

Form childDialog = new Form1
childDialog.Parent = this
childDialog.ShowModal

我的 VB6 有点生疏(而且我没有可用的已安装实例),因此这 子对话框:

Parent.txt_c1 = newValue
if not Parent.Validate then
...
end if

Forms are just classes and can therefore be instantiated explictly (and you will probably find your life easier if you do rather than using the automatic instantiation in VB6) and references to forms can be assigned.

You can solve your problem by creating a public property on your child dialog (Form1.frm) of type Form that you set to the instance of the parent dialog thus giving you access to the controls andd methods on the parent from the child.

My VB6 is somewhat rusty (and I don't have an installed instance available) so this isn't going to be actual, correct code - but something along the lines of the following should work

In the code that calls the child:

Form childDialog = new Form1
childDialog.Parent = this
childDialog.ShowModal

Then in the child dialog:

Parent.txt_c1 = newValue
if not Parent.Validate then
...
end if
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文