多个表单任务


dsUni = new DataSet();
dsUni.ReadXml(pathDesc);
frm02.dgv02.DataSource = dsUni.Tables[0];
frm02.ShowDialog(); // this all works well
dsUni.WriteXml(pathDesc);  // this is in the frm02ClosingEvent

错误:名称 dsUni 和 pathDesc 在当前上下文
中不存在我应该写什么以及在哪里 - 访问从 frm01 到 frm02 的所有控件和所有变量(现在和将来,没有任何限制),反之亦然?

你可以在 dsUni 前面写var,这样你就有一个声明。 pathDesc应该可能包含XML文件的路径,因此必须在其他地方声明它。有关变量范围的介绍,请参阅 http://www.blackwasp.co.uk/CSharpVariableScopes.aspx 或 http://www.codecandle.com/Articles/191/Csharp/Variables/Variable-scope/codedetail.aspx

最新更新