从另一个表单文本框中获取文本框值. [英] Get textbox value from another form textbox.

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

问题描述

大家好,

我试图从Form 1获取一个文本框的值,当Form 2加载时,Form2的文本框应显示该值.我正在使用c#.

任何人都可以帮忙吗?

Hello everybody,

Im trying to get a value of a textbox from Form 1 and when Form 2 loads the textbox of Form2 should show that value. Im using c#.

Anyone can help pls?

推荐答案

感谢ecerybody,您所有的帖子都有用,但是我使用的方式很简单.我只是公开了文本框,然后在Form1上,在加载form2的按钮单击事件中,我设置了文本框value.its起作用;)
Thanks ecerybody,all of your posts where useful,but the way i used was just simple.i just made the textbox public,and then on Form1 ,in the button click event that loads form2 i set the textbox value.its worked ;)


请参阅以下内容:

如何访问textBox值c# [
Refer this:

how to access the textBox value of one form from another form in c#[^]


在Form1.cs中:
In Form1.cs:
private Form2 otherForm;
private void GetOtherFormTextBox()
{
    textBox1.Text = otherForm.TextBox1.Text;
}


在Form2.cs中:


In Form2.cs:

public TextBox TextBox1
{
    get
    {
        return textBox1;
    }
}


这篇关于从另一个表单文本框中获取文本框值.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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