Live Chat Icon For mobile
Live Chat Icon

How can I select the entire row when the user clicks on a cell in the row

Platform: WinForms| Category: Datagrid

Call the DataGrid.Select method from within its mouseup event.

[C#]
private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
	System.Drawing.Point pt = new Point(e.X, e.Y);
	DataGrid.HitTestInfo hti = dataGrid1.HitTest(pt);
	if(hti.Type == DataGrid.HitTestType.Cell) 
	{
		dataGrid1.CurrentCell = new DataGridCell(hti.Row, hti.Column);
		dataGrid1.Select(hti.Row);
	}
}

[VB/NET]
Private Sub dataGrid1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dataGrid1.MouseUp
	Dim pt = New Point(e.X, e.Y)
	Dim hti As DataGrid.HitTestInfo = dataGrid1.HitTest(pt)
	If hti.Type = DataGrid.HitTestType.Cell Then
		dataGrid1.CurrentCell = New DataGridCell(hti.Row, hti.Column)
		dataGrid1.Select(hti.Row)
	End If
End Sub

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.