C#中多个Form之间调用的问题,求大神们指导一下啊。。。
我这里有两个Form1和Formht我在Formht中写了一个Report类并创建了一个Report实例report,然后我想在Form1中也能调用这个实例。。我在Form1中添加了一个Button,在Button中应该写什么代码额。。求大神指导。。。。
[code=C#][/code]public partial class Form1 : Form
{
class Report
{
private _Application wordApp = null;
private _Document wordDoc = null;
public _Application Application
{
get
{
return wordApp;
}
set
{
wordApp = value;
}
}
public _Document Document
{
get
{
return wordDoc;
}
set
{
wordDoc = value;
}
}
// 杀掉winword.exe进程
public void killWinWordProcess()
{
System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("WINWORD");
foreach (System.Diagnostics.Process process in processes)
{
bool b = process.MainWindowTitle == "";
if (process.MainWindowTitle == "")
{
process.Kill();
}
}
}
}
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void 借据合同ToolStripMenuItem_Click(object sender, EventArgs e)
{
//弹出一个新的窗口,显示合同所需填写的部分
Formht f = null;
try
{
f = new Formht();
f.ShowDialog(this);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button3_Click(object sender, EventArgs e)
{
// string RepPath = @"F:\学习\soarto要求\offce小应用";
// Report report = new Report();
// report.SaveDocument(RepPath);
}
[code=C#][/code]
public partial class Formht : Form
{
class Report
{
private _Application wordApp = null;
private _Document wordDoc = null;
public _Application Application
{
get
{
return wordApp;
}
set
{
wordApp = value;
}
}
public _Document Document
{
get
{
return wordDoc;
}
set