我有一个每个dataGridView
行的上下文菜单条,当我点击打印“P.O报告”时,它会打开一个水晶报告,这里是代码:
private void printPOToolStripMenuItem_Click(object sender, EventArgs e)
{
string id = dataGridView1.CurrentRow.Cells[0].Value.ToString();
POreport por = new POreport(Convert.ToInt32(id));
por.Show();
}
这是POreport
类的构造函数:
public POreport(int poId)
{
this.crystalReportViewer1.SelectionFormula = "{poView.poId}="+poId;
}
但每次都会出现NullReferenceException
:
Object reference not set to an instance of an object.