I have ContextMenuStrip to show 2 Menu Item, and I use it on DataGridViewRow. I have a checkBoxColumn to select just 1 row to take an Id and used in another function. So this is my code to selrct the rows.
//get the selected item
List<DataGridViewRow> selectedRows = (from row in Detail_shanuDGV.Rows.Cast<DataGridViewRow>()
where Convert.ToBoolean(row.Cells["checkBoxColumn1"].Value) == true
select row).ToList();
if ((selectedRows.Count > 1) || (selectedRows.Count == 0))
MessageBox.Show("Plz select au moin un ligne...");
else
{
foreach (DataGridViewRow row in selectedRows)
{
//to do functions
}
}
If I try used this code it always give me MessageBox.Show("Plz select au moin un ligne...");
but if I select another row it will show the last row selected.
My problems here that this code not working with ContextMenuStrip or MenuStrip, it works only with buttons.