c#的form编程中,我想实现在一相窗口中定义变量,同时再另一个窗口调用?

来源:百度知道 编辑:UC知道 时间:2024/04/27 19:43:32
怎么实现?

就可以了,这属于窗体间参数传递,有很多的方法!
其中一个
A窗口
在A:窗口中public string PublicString;
B窗口
调用A
A a=new A();
a.PublicString="自定义变两";
a.show();

public

Form1.cs
private void button1_Click(object sender, System.EventArgs e)
{
string Name = textBox1.Text;
string Subject = comboBox1.SelectedItem.ToString();
string Symbol = comboBox2.SelectedItem.ToString();
AnotherForm form = new AnotherForm(Name, Subject, Symbol);
//form.Show(); // To show the form modelessly
form.ShowDialog(); // To show the form modally
}

============================================
AnotherForm.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace WindowsApplication12
{
/// <summary>
/// Summary description for AnotherForm.
/// </summary>
public cl