如何使用其他形式在form1的文本框中输入的值

How to use a value from entered in textbox of form1 in other forms [duplicate]
2020-11-21
  •  译文(汉语)
  •  原文(英语)

我也希望以登录形式输入的用户名(txtusername)也可以其他形式(例如form2)使用,以便我可以在cmd.parameters.addwithvalue("@ last_updated_user",txtusername.text)中使用它们.以及form2中的其他参数(文本框值).最新费用更新

速聊2:
您尝试/研究了什么?如果您将"答案"复制到Google中,则需要重复多个答案
解决过程1
You can use static vars, which would be the easiest solution but  if you have multiple instances and you change the static varibale in just one the change will also effect all other instances. , personally I think constructors 
so

create a constuctor for the second form which accepts 2 arguments 

i.e 

FormWhatevz form2= new FormWhatevz (textBox1.Text,textBox2.Text);
" in Form1 Code or anywhere really.."

form2.Show(); 

Constructor:

public FormWhatevz(string loginUserName,string Password)
    {
        InitializeComponent();
        textbox1value.Text = loginUserName;
        textbox1value.Text=Password; 

    }

Hope this helps , this source shows multiple ways of parsing data
between forms , source : http://www.codeproject.com/Articles/14122/Passing-Data-Between-Forms       

I want the user name(txtusername) entered in login form to be available in other forms(say form2) too so that i can use them in cmd.parameters.addwithvalue("@last_updated_user",txtusername.text); along with other parameters (textbox values) in form2. latest cost update

Talk2:
What have you tried/researched? if you copy your "answer" into google there are multiple duplicates with the answer you need
Solutions1
You can use static vars, which would be the easiest solution but  if you have multiple instances and you change the static varibale in just one the change will also effect all other instances. , personally I think constructors 
so

create a constuctor for the second form which accepts 2 arguments 

i.e 

FormWhatevz form2= new FormWhatevz (textBox1.Text,textBox2.Text);
" in Form1 Code or anywhere really.."

form2.Show(); 

Constructor:

public FormWhatevz(string loginUserName,string Password)
    {
        InitializeComponent();
        textbox1value.Text = loginUserName;
        textbox1value.Text=Password; 

    }

Hope this helps , this source shows multiple ways of parsing data
between forms , source : http://www.codeproject.com/Articles/14122/Passing-Data-Between-Forms       
转载于:https://stackoverflow.com/questions/28361888/how-to-use-a-value-from-entered-in-textbox-of-form1-in-other-forms

本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文

留言回复
我们只提供高质量资源,素材,源码,坚持 下了就能用 原则,让客户花了钱觉得值
上班时间 : 周一至周五9:00-17:30 期待您的加入