将ID从一种形式传递到另一种形式

问题描述:

我已经开发了Windows应用程序.
在这种情况下,我想将某些数据从一种形式传递到另一种形式.
怎么做.
如果有人有想法请提出建议.
在此先谢谢您.

I have develop windows application.
In that i want to pass some data from one form to other from.
How to do this.
If any one have idea pls suggest it.
Thanks in advance.

检查此CP文章
在表单之间传递数据 [
在Windows窗体之间传递数据
[^ ]
在Windows窗体和对话框之间传递数据 [在表单之间传递变量 [ ^ ]
Check this CP article
Passing Data Between Forms[^]


Few more resources
Passing Data Between Windows Forms
[^]
Passing Data Between a Windows Form and Dialog Boxes[^]
Passing Variables between Forms[^]


在Windows应用程序中将变量从一种形式传递到另一种形式:
在第一种形式的按钮"下单击这样的文本

Passing Variable from one form to another form in windows application:
In first form Under Button click wirte like this

private void button1_Click(object sender, EventArgs e)
       {
           Display d = new Display(textBox1 .Text );
           d.Show();
       }


然后以秒形式写这样


Then In secound Form write like this

public partial class Display : Form
    {
        string str;// declare string to strore value

//constructor to load value
        public Display(string txt)
        {
            InitializeComponent();
            str = txt;
        }
//form load 
        private void Display_Load(object sender, EventArgs e)
        {
            label1.Text = str;
        }
    }


看看:
将数据从一种形式传递到另一种形式 [ ^ ]

如果您在所有表单上都使用ID,则只需在类文件program.cs
中使用静态属性 像这样的东西:
Have a look:
Pass Data from One Form to Another Form[^]

If you are using ID on all form, you can simply use static property in your class file program.cs
Something like this:
public static Int ID
        {
            get;
            set;
        }