如何使用表单的对象将数据从WINDOWS表单传递到另一个CLASS? [英] How to Pass data from a WINDOWS Form to a another CLASS using the form's object?
本文介绍了如何使用表单的对象将数据从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
这篇关于如何使用表单的对象将数据从WINDOWS表单传递到另一个CLASS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文