private void DG_ContextMenuOpening(object sender, ContextMenuEventArgs e) { if (DG.SelectedIndex == -1) { return; } var item = (DG.Items[DG.SelectedIndex] as SHOW); Objecte obj = AllClients.ObjecteAtWell(item.ID); List <SelectionWell> SW = new List <SelectionWell>(); foreach (SHOW one in DG.SelectedItems) { SW.Add(one.SelectionWell); } Sample sample = SW.First().Sample; DG.ContextMenu.Items.Clear(); MenuItem miCalc = new MenuItem { Header = "Расчёт" }; miCalc.Click += (senderC, eC) => { if (item.Volume.Length > 0) { new CalculationFees_Print_Class(sample); } else { MessageBox.Show("Объём не задан!"); } }; DG.ContextMenu.Items.Add(miCalc); MenuItem miExtract = new MenuItem { Header = "Выписка" }; miExtract.Click += (senderE, eE) => { print = new Extract_Print_Class(sample); print.Start(); }; DG.ContextMenu.Items.Add(miExtract); MenuItem miProtocol = new MenuItem { Header = "Протокол" }; miProtocol.Click += (senderE, eE) => { print = new Protocol_Print_Class(SW.ToArray()); print.Start(); }; DG.ContextMenu.Items.Add(miProtocol); MenuItem miInspectionResult = new MenuItem { Header = "Результат контроля" }; miInspectionResult.Click += (senderE, eE) => { print = new InspectionResult_Print_Class(obj.ID); print.Start(); }; DG.ContextMenu.Items.Add(miInspectionResult); }