如何使用表单的对象将数据从WINDOWS表单传递到另一个CLASS?
问题描述:
表单的所有属性都应该在类中可用,如文本框,按钮等。
最初我知道如何将表单对象传递给另一个类,但是表单的属性我是无法取得它。因为我必须得到类中表格中存在的一些文本框的值。
All the properties of the Form should be available in the class like textbox, button etc.
Initially I know how to pass the form object to another class but the properties of the form I'm unable to fetch it. As I have to get the values of some textboxes present in the form in class.
答
你好b $ b
你可以试试如下所示:
Hi
You can try as below :
public yourclassconstructor(Form1 frm )
{
TextBox txtBox = (TextBox)frm.Controls["textBox1"];
string text = txtBox.Text;
}
问候
Dominic Abraham
Regards
Dominic Abraham