private void Right_Click(object sender, EventArgs e) { MouseEventArgs me = (MouseEventArgs)e; if (me.Button == System.Windows.Forms.MouseButtons.Right) { var hti = DGVArticles.HitTest(me.X, me.Y); if (hti.RowIndex >= 0) { DGVArticles.ClearSelection(); DGVArticles.Rows[hti.RowIndex].Selected = true; } ContextMenu cm = new ContextMenu(); cm.MenuItems.Add("Dodaj artikal", new EventHandler(AddNewArtical_Click)); if (DGVArticles.SelectedRows.Count == 1) { cm.MenuItems.Add("Izmeni artikal", new EventHandler(EditRow_Click)); } cm.Show(DGVArticles, new Point(me.X, me.Y)); } }