How do I select a complete dataGridView Row when the user clicks a cell of that row?

get the selected row in datagridview c# on button click
datagridview row click event
how to get cell value from datagridview in c# windows application
datagridview get selected row
c# datagridview get selected row data
how to get multiple selected rows in datagridview c#
how to get selected row value in datagridview in c# windows application
cell content click event in datagridview c#

I have a dataGridView and I need that when the user clicks on any cell the whole row that contains this cell is selected too. (it has multiselect disbaled) I tried getting the currentRowIndex like this

 int Index = dataGridView1.CurrentCell.RowIndex;

However, I am not sure how to use the index in order to select that row. Tried this and about other six ways with no success:


Do you know a way I can do this?

You need to set datagridview's SelectionMode to FullRowMode.

Note: In Visual Studio 2013 with .NET 4.5 the property is called FullRowSelect, see

Force DataGridView Entire Row selection, This code works fine to Select the whole row when the user clicks on any cell in the DGV: private void dataGridView1_CellClick(object sender,  How do I select a complete dataGridView Row when the user clicks a cell of that row? You need to set datagridview's SelectionMode to FullRowMode. Note: In Visual Studio 2013 with .NET 4.5 the property is called FullRowSelect,

If you want the row selected programatically, you would use the datagridview's cell click event: shown in and C#


Private Sub dgvGrid_CellClick(sender as System.Object, e as System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvGrid.CellClick
    If e.RowIndex < 0 Then
        Exit Sub
    End If

    intIndex = e.RowIndex
    dgvGrid.Rows(intIndex).Selected = True
Exit Sub


private void dgvRptTables_CellClick(System.Object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
    if (e.RowIndex < 0) {

    int index = e.RowIndex;
    dgvGrid.Rows[index].Selected = true;

Selection Modes in the Windows Forms DataGridView Control, Clicking a cell or a row header selects the entire row. Default selection mode. Clicking a cell selects it. Clicking a row header selects the entire row. By default, users can select multiple rows, columns, or cells by dragging with the mouse, pressing CTRL or SHIFT while selecting to extend or modify a selection, or clicking the top-left header cell to select all cells in the control. To prevent this behavior, set the MultiSelect property to false.

datagridview cell click event c#, Get Selected Row Values From , Follow these steps. Add a datagridview from toolbox in your form. 2. go to the property window Duration: 7:26 Posted: Jan 22, 2018 You can simulate clicks on grid cells using the ClickCell, ClickCellR, DblClickCell and similar actions of the MisrosoftDataGridView object. All of these actions have parameters that specify the row and column that contain the desired cell.

Could do something like this

protected override void Render(HtmlTextWriter writer)
    foreach (GridViewRow row in Results.Rows)
        if (row.RowType == DataControlRowType.DataRow)
            row.Attributes["onmouseover"] = "'pointer';";
            row.CssClass = "rowHover";
            row.ToolTip = "Click row to view person's history";
            row.Attributes.Add("onclick", this.ClientScript.GetPostBackClientHyperlink(this.Results,"Select$" & r.RowIndex , true));


Microsoft.NET Compact Framework: Kick Start, in the DataGrid The DataGrid control can have either an entire row or a single cell selected. To determine which cell or row the user clicked, you should use the​  I want to select a row in my DataGridView with a right click. But with my current code I first have to click on the row with a regular left mouse click. Is there any way to select the current row with a right click and than open a ContextMenuStrip?

//class to store ID (Pri. Key) value of selected row from DataGridView
public class Variables
   public static string StudentID;

//This is the event call on cell click of the DataGridView
private void dataGridViewDisplay_CellClick(object sender, DataGridViewCellEventArgs e)
   Variables.StudentID =this.dataGridViewDisplay.CurrentRow.Cells[0].Value.ToString();
//textBoxName is my form field where I set the value of Name Column from the Selected row from my DataGridView 

   textBoxName.Text = this.dataGridViewDisplay.CurrentRow.Cells[1].Value.ToString();

   dateTimePickerDOB.Value = Convert.ToDateTime(this.dataGridViewDisplay.CurrentRow.Cells[2].Value.ToString());

Take a look at My DataGridView

Microsoft Visual C# 2005 Unleashed, Working with the DataGridView The DataGridView is much like its predecessor in provides for a grid-like display of rows and columns of data from an underlying data source. For a complete list of all events, and methods, and properties, see the MSDN CellBeginEdit Occurs when the selected cell goes into edit mode. dataGridView.Rows[0].Selected = true;//determine index value from your logic dataGridView.Rows[5].Selected = true; EDIT Instead of row select then you can try this logic, subscribe to the rowheaderclick event wherein you would get the row index for which it was clicked, now loop through the columns and set each cell as selected (similar to above)

Flash Builder 4 and Flex 4 Bible, When the user clicks in a cell, it displays the CheckBox control. If you Want the item editor component to be displayed in every roW of the DataGrid, follow these the user has clicked into the cell: <mX:DataGridColumn dataField:"selected“  An extra twist is that when I do not apply a RowFilter to the DataGridView the problem doesn't exist. My guess is that when I click the cells of the DataGridView, the program filters the whole grid contents, effectively removing the summary view in the process.

Row Selection: Core Feature of our Datagrid, Row Selection: Select rows, Choose between click selection or checkbox selection, 'single' will use single row selection, such that when you select a row​, any previousCellDef; // set selected cell on current cell + 1 gridOptions.api. You can select a single row programmatically by setting its IsSelected property to true: Both ways of selecting a single row will result in adding this row into the RadGridView. SelectedRows collection. You can select multiple rows programmatically by setting their IsSelected property to true: ClearSelection () RadGridView1.

Selecting Cells in Microsoft DataGridView, When testing Microsoft DataGridView controls, use specific methods and properties of the You can simulate clicks on grid cells using the ClickCell , ClickCellR have parameters that specify the row and column that contain the desired cell. You can get the selected cells, rows, or columns from a DataGridView control by using the corresponding properties: SelectedCells, SelectedRows, and SelectedColumns. In the following procedures, you will get the selected cells and display their row and column indexes in a MessageBox. Use the SelectedCells property.

  • Hahah Much more simpler than I thought. Thank you.
  • Use: dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  • How will I bind the event with datagridview?