将ID从一种形式传递到另一种形式 [英] Pass Id from one form to other form

查看:74
本文介绍了将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;
        }


这篇关于将ID从一种形式传递到另一种形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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