110,566
社区成员
发帖
与我相关
我的任务
分享
public class MyEventArgs : EventArgs
{
public DataTable dtData;
public MyEventArgs(DataTable dt)
{
dtData = dt;
}
}
public event EventHandler<MyEventArgs> DataSended;
if (DataSended!= null)
DataSended(this, new MyEventArgs(子窗体中的DataTable对象));
子窗体.DataSended += new EventHandler<MyEventArgs>(函数名);
private void 函数名(object sender, MyEventArgs e)
{
// e.dtData就是子窗体中的DataTable
// 如果只是DataTable的处理,写代码就行了
// 如果还要做界面控件的访问,则需要使用代理。
}
objdgv = new DataGridView();
DataTable objDataSet = new DataTable();
mpu_15booktree objForm = new mpu_15booktree("m_material_group", "<%1>Y",this.Name);
objForm.Show();
//这是返回datatable后要执行的动作
objDataSet = (DataTable)objdgv.DataSource;
string str_style=null;
for(int i = 0;i<objDataSet.Rows.Count;i++)
{
str_style+=objDataSet.Rows[i]["field"].ToString()+"',";
}
txt_workstation_style.Text=str_style.Substring(0,str_style.Length-2);
public static DataTable g_dt_booktree;//这个是要操作的datatable
DataGridViewSelectedRowCollection rowColl = grd_booktree.SelectedRows;
if (rowColl == null)
{
return;
}
DataTable totalDT = (DataTable)grd_booktree.DataSource;
if (totalDT == null)
{
return;
}
g_dt_booktree = totalDT.Clone();
for (int i = 0; i < rowColl.Count; i++)
{
DataRow dataRow = (rowColl[i].DataBoundItem as DataRowView).Row;
g_dt_booktree.ImportRow(dataRow);
}
//操作完后我如何把值返回给父窗体 并执行父窗体的代码呢?