private void OnItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { switch (e.Item.Tag.ToString()) { case "刷新": ReLoad(); break; case "新增": DoCreateLocation(); break; case "修改": ShowEditLocation(); break; case "删除": DoDeleteSelectedLocation(); break; case "打印": DoPrint(); break; case "设计": RibbonReportDesigner.MainForm designForm = new RibbonReportDesigner.MainForm(); RepLocation rep = new RepLocation(); try { designForm.OpenReport(rep, rep.RepFileName); designForm.ShowDialog(); designForm.Dispose(); } catch (Exception ex) { MsgBox.Err(ex.Message); } break; case "快速查找": if (gridView1.IsFindPanelVisible) { gridView1.HideFindPanel(); } else { gridView1.ShowFindPanel(); } break; } }
private void DoPrint() { int[] selectedIndex = gridView1.GetSelectedRows(); if (selectedIndex.Length == 0) { MsgBox.Warn("请选中要打印的行。"); return; } if (MsgBox.AskOK("确定开始打印吗?") == DialogResult.OK) { List <LocationEntity> locations = new List <LocationEntity>(); foreach (int i in selectedIndex) { if (i >= 0) { locations.Add(gridView1.GetRow(i) as LocationEntity); } } RepLocation repLocation = new RepLocation(locations, 1); repLocation.Print(); } }