Hi
I have a datagridview (not bound to data source). I need to change some cells values based on the selection made using contextMenuStrip
I have two different contextMenuStrips. One for Type and one for Price.
This is an example for one of the types if selected.
//This will change the selected rows/by its cells with the value USA
private void Type_USA()
{
if (dgv1.SelectedRows.Count > 0)
{
DataGridViewSelectedRowCollection mc= dgv1.SelectedRows;
for (int i = 0; i < mc.Count; i++)
{
DataGridViewRow row = mc[i];
row.Cells[2].Value = "USA";
}
}
}
Currently, in DGV1_CellValueChanged() I have this:
if (dgv1.Columns[e.ColumnIndex].Name == "Type")
{
Type_USA();
}
But, I don't want to call it there, but else, I need to enable the right click button to call the right context menu based on the column name and
assign the value of the cell.
How can I do that? How can I apply the method that I implemented to be fired ones the user selected from the contextMenu by the Mouse_ rightclick ?