datagrid fullrow select

D

Dan

How can I select the full row in a datagrid? I tried the code below (from
the Syncfusion windows forms faq), so that all the cells of a row are
selected when I click on a single cell, BUT this has the effect of not
allowing multiple rows selection (ctrl-click or shift-click). How can I fix
this?

Thanx!

private void DataGrid_MouseUp(object sender, MouseEventArgs e)
{
DataGrid dg = (DataGrid)sender;
System.Drawing.Point pt = new Point(e.X, e.Y);
DataGrid.HitTestInfo hti = dg.HitTest(pt);
if (hti.Type == DataGrid.HitTestType.Cell)
{
dg.CurrentCell = new DataGridCell(hti.Row, hti.Column);
dg.Select(hti.Row);
}
}
 
G

Gary Vidal

This code worked for me.

Private Sub dgList_RowChanging(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles dglist.CurrentCellChanged

dglist.Select(dglist.CurrentCell.RowNumber)

End Sub
 
D

Dan

Thanks, but I keep getting the same problem: with any of the two solutions I
can select multiple rows with ctrl/shift-click ONLY if I click on the
leftmost portion of the grid (where the small triangle 'cursor' is shown);
when I click on a row cell the whole row is selected, but only 1 row at once
can be selected (when I ctrl/shift-click onto another row's cell, the
previous row is deselected).
Any idea?
 
G

Gary Vidal

I tested the function it seems that if you double click the row header (the little box next to the row) it will select a row. Its weird but it works
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top