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.

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);

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)
	End If
End Sub

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

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

Please submit your question and answer.