如何从一个表单访问另一个表单vb.net [英] How get access from one form to another form vb.net

查看:117
本文介绍了如何从一个表单访问另一个表单vb.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两种形式。

在第一种形式中有TextBox1

我希望从第二种表单中获取此属性,这会调用点击第一个表单。

谢谢

VB.NET上的代码

I have two forms.
In the first form there is TextBox1
I want get this property from second Form, that calls about click first form.
Thank you
Code on VB.NET

推荐答案

很难弄清楚你在尝试什么在这里做 - 你的问题不是很清楚。

所以我真的不能给你代码!



让我们说你有两种形式:Form1和Form2。 Form1有一个文本框。



如果Form1上的按钮打开Form2,你想在From2上设置一个值到文本框的内容:

1)创建一个带有字符串参数的Form2构造函数,并直接用字符串构造它,



2)在Form2中创建一个字符串属性,它可以接受该值,

2.1)在创建它之后和调用ShowDialog之前设置Form2实例属性。



如果你想要一个按钮在Form2上从Form1获取一个值然后这有点复杂 - 问我会告诉你。
It''s difficult to work out exactly what you are trying to do here - your question is not very clear.
So I can''t really give you code!

Lets say you have two forms: Form1 and Form2. Form1 has a textbox.

If a button on Form1 opens Form2 and you want to set a value on From2 to the content of the textbox:
1) Either create a Form2 constructor that take a string parameter, and construct it with the string directly,
or
2) Create a string property in Form2 which can accept the value,
2.1) Set the Form2 instance property after your create it and before you call ShowDialog.

If you want a button on Form2 to fetch a value from Form1 then that is a little more complex - ask and I''ll tell you.


这篇关于如何从一个表单访问另一个表单vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆