protected virtual void OnReportElementAdding(ReportElementEventArgs e) { EventHandler <ReportElementEventArgs> handler = (EventHandler <ReportElementEventArgs>)Events[ReportElementAddingEvent]; if (handler != null) { handler(this, e); } }
void SubMenuItem_Click(object sender, EventArgs e) { Object value = null; ToolStripMenuItem MenuItem = sender as ToolStripMenuItem; if (MenuItem != null) { switch (MenuItem.Text) { case "数据列": value = new ReportCommon.DataColumn(); break; case "普通文本": value = new LiteralText(); break; case "公式": value = new Formula(); break; case "图表": value = new ChartPainter(); break; case "图片": value = new ReportCommon.Picture(); break; case "斜线": value = new Slash(); break; case "变量": value = new Variable(); break; } if (value != null) { ActiveSheet.ActiveCell.CellType = general; ReportElementEventArgs elementevent = new ReportElementEventArgs(); elementevent.Value = value; OnReportElementAdding(elementevent); } else { String msg = "当前版本不支持" + MenuItem.Text + "报表元素。"; MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }