I explain what I need: I want, by right clicking on a cell of a DataGridView
that I was displayed a menu on it (on the cell) .
The problem is: When you right-click the menu, it always appears in the upper part of DataGridView
and NO in the clicked cell.
I clicked right where the red dot is but in any case the menu appears in the upper sector of DataGridView
, and so in any place that right clicks.
Time to show code: The following code is the function I have so far.
private void lista_dias_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
ContextMenuStrip menu = new ContextMenuStrip();
int posiscion = lista_dias.HitTest(e.X, e.Y).RowIndex;
// if (posiscion >= 0) {
menu.Items.Add("agregar").Name = "AGREGAR";
menu.Items.Add("eliminar").Name = "Eliminar";
menu.Items.Add("detalles").Name = "DETALLES";
//}
menu.Show(lista_dias, new Point(e.X, e.Y));
}
}
This event was created automatically from the interfaces that has C #, the event is CellMouseClick
.
Thank you in advance for the help.