enable multi selection in dataGrid

G

Guest

Hi,

I've a dataGrid which i overide the MouseUp event.
now, the user can select only one row, and i want to give the user the
option to select few rows when he presses the CTRL+Mouse (like usually done),
and i can't find the way to do it.


my MouseUp function looks like this:

private void dataGrid1_MouseUp(object sender, 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);
}
m_row=dataGrid1.CurrentCell.RowNumber;
}

Thanks,
Gidi
 
G

Guest

I don't think I understand what you are trying to achive with the code you
posted. To enable multi row selection in a datagridview, make sure the
MultiSelect property is set to true and the SelectionMode of the datagridview
is set to FullRowSelect. This way you can select single rows by clicking on
them once with the mouse, and multiple rows by holding down ctrl and clicking
on them with the mouse which is what I think you are after.

Adrian.
 

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