VB6中父对话框的访问控制
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
表单只是类,因此可以显式实例化(如果这样做而不是使用 VB6 中的自动实例化,您可能会发现生活更轻松),并且可以分配对表单的引用。
您可以通过在 Form 类型的子对话框 (Form1.frm) 上创建一个公共属性来解决您的问题,并将其设置为父对话框的实例,从而使您可以从子对话框访问父对话框的控件和方法。
不会是实际的、正确的代码 - 但以下内容应该可以
在调用子项的代码中工作:
我的 VB6 有点生疏(而且我没有可用的已安装实例),因此这 子对话框:
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:
Then in the child dialog: