如何以另一种形式访问一个表单变量? [英] How to access one form variable in another form?
本文介绍了如何以另一种形式访问一个表单变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
第1张表格
名称空间 TestApp
{
public partial class Form1 :Form
{
string testrun = 一个跨度>;
// public string testrun {get;组; }
public string 名称{
< span class =code-keyword> get { return 名称; }
set {Name = testrun; }
}
}
}
这里我通过了testrun值到名称变量
第二表格
<前lang =cs> private void button1_Click( object sender,EventArgs e)
{
Form1 f3 = new Form1();
// f3.SomePropertyName =hello from form2;
textBox1。 Text = f3.Name;
}
这里我将名称变量传递给文本框.......
基本上我想把第二个表格的testrun值显示在第二个表格文本框中。
解决方案
你好,请看这个链接:
代码:从另一个表单中获取值 [ ^ ]
或查看此主题:
在C#表单之间设置值 [ ^ ]
C#在其他窗体中访问变量类 [ ^ ]
希望它有所帮助! :)
你好专业
试试吧这样..
我将如何向用户展示使用c #windows应用程序命名到表单顶部的另一个页面? [ ^ ]
它会帮助你
乐于助人!!!
1st Form
namespace TestApp
{
public partial class Form1 : Form
{
string testrun = "one";
//public string testrun { get; set; }
public string Name {
get { return Name; }
set { Name = testrun; }
}
}
}
here i'm Passing the testrun values to Name variable
2nd Form
private void button1_Click(object sender, EventArgs e)
{
Form1 f3 = new Form1();
//f3.SomePropertyName = "hello from form2";
textBox1.Text = f3.Name;
}
Here i'm passing the name variable to the textbox.......
basically i want to get testrun value to the second form and display it in the 2nd form textbox.
解决方案
Hi, See this link:
Code: Getting a Value from Another Form[^]
Or See this thread:
Pasing values between C# forms[^]
C# Accessing variables in other windows form class [^]
Hope it helps! :)
hello professional
try it ton this way..
how would i show my user name to another page top of the form using c# windows application?[^]
it will help you
Happy to Help!!!
这篇关于如何以另一种形式访问一个表单变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文