Made a right-click menu for Datagridview . But I can not understand, I launched the application, I clicked 1 time, the menu does not appear, clicked a second time - it appeared and then the rules are already working, I close, open the form again, the same problem, the first time I’ll not open, then the rules work. What am I doing wrong?
private void dataGridView1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { try { ContextMenuStrip shift_my_menu = new System.Windows.Forms.ContextMenuStrip(); int position_x_y_mouse = dataGridView1.HitTest(eX, eY).RowIndex; if (position_x_y_mouse >= 0) { shift_my_menu.Items.Add("Редактировать").Name = "edit"; shift_my_menu.Items.Add("Удалить").Name = "del"; } shift_my_menu.Show(dataGridView1, new Point(eX, eY)); shift_my_menu.ItemClicked += new ToolStripItemClickedEventHandler(shift_my_menu_ItemClicked); shift_my_menu.Items["del"].Image = MSU.Properties.Resources.delete; shift_my_menu.Items["edit"].Image = MSU.Properties.Resources.edit;
Visibleproperty). - Alexander Petrovdatagridview, I call the menu in the main window with the same method, there is no such problem. Could this be due to the fact that the window is extra? - Winteriscomingdatagridviewmenu while active. - Winteriscoming