从form1 combox到form2标签C#的值 [英] Value from form1 combox to form2 label C#

查看:78
本文介绍了从form1 combox到form2标签C#的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在测试应用上做这个



Combobox public



我的测试应用工作正常,在我的工作应用程序不工作。



有些帮助吗?



我的尝试:



Form1



I make this on test app

Combobox public

On my test app working fine, on my work app dont work.

Some help?

What I have tried:

Form1

public static string godina { get; set; }







private void loginButton_Click(object sender, EventArgs e)
       {
           prijava();

           godina = comboBox1.Text;
       }





Form2





Form2

InitializeComponent();
godinalabel.Text = getGodina();







private String getGodina()
        {

            string value = Form1.godina.ToString();
           
            return value;
        }

推荐答案

不要进行表单控件 public it意味着你不能在不考虑对世界其他地方的可能影响的情况下再次改变形式。



你究竟是如何做到这一点取决于你们之间的关系这两种形式。

看看这些,其中一个适合你的情况。

创建另一个实例的表格:

Don;t make form controls public it means that you can't change the form again without considering the possible effects on the rest of the world.

Exactly how you do this depends on the "relationship" between the two forms.
Have a look at these, one of them will fit your circumstances.
The form that creates an instance of another:
MyForm mf = new MyForm();
mf.Show();

是父,另一种形式是孩子。

(这并不意味着任何正式的MDI关系)



转让两种表格之间的信息,第1部分:父母与子女 [ ^ ]

在两种表格之间传递信息,第2部分:儿童到父母 [ ^ ]

在两种形式之间传递信息,第3部分:儿童到儿童 [ ^ ]

Is the "parent", the other form is the "child".
(This doesn't imply any formal MDI relationship)

Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]


这篇关于从form1 combox到form2标签C#的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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