我想在mainform 窗体下调用txtform中的print——click方法,但是弹出了"pring_click" 方法没有采用“0”个参数的重载错误,哪个大侠给说说那错了??
public partial class mainform : Form
{
private void 打印ToolStripMenuItem_Click(object sender, EventArgs e)
{
txtform tf = new txtform(); tf.print_Click(); { };
}
}
public partial class txtform : Form
{
public void print_Click(object sender, EventArgs e)
{
if (shouanalyse.Text != string.Empty)
{
pageSetupDialog1.Document = printDocument1;
this.pageSetupDialog1.AllowMargins = true;
this.pageSetupDialog1.AllowOrientation = true;
this.pageSetupDialog1.AllowPaper = true;
this.pageSetupDialog1.AllowPrinter = true;
this.pageSetupDialog1.ShowDialog();
if (MessageBox.Show("是否要打印玉兰文档,", "打印预览", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
this.printPreviewDialog1.Document = this.printDocument1;
printPreviewDialog1.ShowDialog();
}
else
{
printDocument1.Print();
}
}
else
{
MessageBox.Show("请输入要打印的信息");
}
} public void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawString(shouanalyse.Text, new Font("宋体", 8), Brushes.Black,90,10);
}
}
public partial class mainform : Form
{
private void 打印ToolStripMenuItem_Click(object sender, EventArgs e)
{
txtform tf = new txtform(); tf.print_Click(); { };
}
}
public partial class txtform : Form
{
public void print_Click(object sender, EventArgs e)
{
if (shouanalyse.Text != string.Empty)
{
pageSetupDialog1.Document = printDocument1;
this.pageSetupDialog1.AllowMargins = true;
this.pageSetupDialog1.AllowOrientation = true;
this.pageSetupDialog1.AllowPaper = true;
this.pageSetupDialog1.AllowPrinter = true;
this.pageSetupDialog1.ShowDialog();
if (MessageBox.Show("是否要打印玉兰文档,", "打印预览", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
this.printPreviewDialog1.Document = this.printDocument1;
printPreviewDialog1.ShowDialog();
}
else
{
printDocument1.Print();
}
}
else
{
MessageBox.Show("请输入要打印的信息");
}
} public void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawString(shouanalyse.Text, new Font("宋体", 8), Brushes.Black,90,10);
}
}
--------------------------
tf.print_Click(sender,e);