再Form1中加入一個全局變量, 點擊Form2的確定後先對Form1的那個全局變量進行賦值,在Form1中的那個需要傳遞的參數就用這個全局變量來代替,不就好了,不過耗時線程建議不要放在Form中
解决方案 »
- c# winform Devpress.XtraGrid.GridControl.GridView
- 这段代码什么地方有问题?
- 为什么reportviewer导出excel时后空列。。。
- C# 结构中的数组如何赋值?
- 利用多线程从长时间运行的操作中分离出用户界面的问题
- 最近在学习WPF,哈哈哈哈哈
- 有关Datagrid 控件问题?
- 查询数据时,显示等待图片
- 高手请赐教:Asp.net(c#)部署的问题:Could not load type 'MyApp.Global'
- 怎样用多线程显示多个form?
- FORM控件如何刷新显示呀?
- 程序"F:\csharp\windowsapplication1\obj|debug\windowsapplication1.exe"未定義入口點
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(80, 80);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 0;
this.textBox1.Text = "textBox1";
//
// button1
//
this.button1.Location = new System.Drawing.Point(88, 136);
this.button1.Name = "button1";
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// frmMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Name = "frmMain";
this.Text = "Form1";
this.ResumeLayout(false);
me.OnMessage += new frmNext.Message(this.txtMessage); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new frmMain());
} private void txtMessage(string str)
{
this.textBox1.Text = str;
} private void button1_Click(object sender, System.EventArgs e)
{
me.writeMessage("hello from main");
me.Show();
} }
以上为Form1 private void button1_Click(object sender, System.EventArgs e)
{
this.OnMessage("Hello");
}
public void writeMessage(string str)
{
this.textBox1.Text = str;
} private void frmNext_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;;
this.Hide();
}
//form2
public class WorkThread
{
//下面定義一些變量
public int nPort = -1;
public WorkThread()
{
}
//下面是工作函數
public void Work()
{
//Some work code
}
}//下面是調用
WorkThread oWork = new WorkThread();
oWork = 10;
Thread t = new Thread(new ThreadStart(oWork.Work)
t.IsBackGround = true;
t.Start();這樣在Work函數要耗掉很多CPU時間的情況下,你的主程序介面刷新也不會受到影響
没看懂!还请指教!