I wanted to add a context menu to a DataGridView, allowing the user to perform an action on a specific row. However, right clicking in a DataViewGrid does not change the selected row. This can be achieved by adding the following code to the CellMouseDown event (the name of my grid is dgvWorkflows):
private void dgvWorkflows_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e){ if (e.ColumnIndex >= 0 && e.RowIndex >= 0) { dgvWorkflows.CurrentCell = dgvWorkflows.Rows[e.RowIndex].Cells[e.ColumnIndex]; }}
dasBlog theme by Mads Kristensen
Concepts LINQ Entity Framework WCF WPF RESTful Web Unit Testing .NET Workflow More >>
Tools Visual Studio Windows IIS Silverlight More >>
Type Screencast Tools Video Newsletter Sample Article Books Magazine How To Demo Course Products More >>