基本信息
源码名称:C# PassingValueFromToForm 視窗傳值
源码大小:0.14M
文件格式:.rar
开发语言:C#
更新时间:2016-06-01
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍
PassingValueFromToForm 視窗傳值



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PassingValueFromToForm
{
    //Refer: http://www.codeproject.com/Articles/14122/Passing-Data-Between-Forms
    public partial class Form1 : Form
    {        
        // For Delegates Use
        public delegate void delPassData(TextBox text);

        // For Public Value Use
        public static string str;
        public static string str2;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // The Constructor Approach
            if (rbConstructor.Checked == true)
            {
                str2 = rbConstructor.Text;

                Form2 frm = new Form2(textBox1.Text);
                frm.Show();
            }
            // The Public Value Approach
            else if (rbPublicValue.Checked == true)
            {
                str2 = rbPublicValue.Text;

                str = textBox1.Text;                
                Form2 frm = new Form2();
                frm.Show();
            }
            // The Properties Approach
            else if (rbProperty.Checked == true)
            {
                str2 = rbProperty.Text;

                Form2 frm = new Form2();
                frm._textBox = _textBox1;
                frm.Show();
            }
            // The Delegates Approach
            else if (rbDelegate.Checked == true)
            {
                str2 = rbDelegate.Text;

                Form2 frm = new Form2();
                delPassData del = new delPassData(frm.funData);
                del(this.textBox1);
                frm.Show();
            }
        }

        public string _textBox1
        {
            get { return textBox1.Text; }
        }
    }
}