form1 构造函数中加一个form实体,把form2直接当参数传过去,在form1中实例一个form 这个form=form2
再调用form2的方法,给你个例子
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Windows.Forms;
namespace 呼叫器
{
public partial class 特呼表 : Form
{
Form form;
public 特呼表(string PCName, object timeOut, string docName, string currentOfficeName,Form form)
{
// TODO: Complete member initialization
InitializeComponent();
this.PCName = PCName;
this.timeOut = timeOut;
this.docName = docName;
this.currentOfficeName = currentOfficeName;
this.form = form;
}
private void 特呼表_Load(object sender, EventArgs e)
{
}
private void dgvPatient_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
form.Refresh();
}
你只需要在form2中写一个public方法用来提交数据,然后在form1中调用不就行了?
如果直接调用其他窗口的控件可能会导致线程安全问题,最好使用委托来实现