嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在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; }
}
}
}