Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Grid - Select whole row when cell selected 1

Status
Not open for further replies.

spangeman

Programmer
Oct 16, 2004
96
EU
Hello

I would like to be able to code my data grid (2005) so that when one cell is selected the whole row is selected instead.

So everytime a cell is clicked on the whole row is selected as if the user had click to the far left to select the whole row.

Cheers
Spangeman
 
i had to dig a bit for this... I just could not remember how :(
Anyway the way to do it is to use the DataGridViewSelectionMode.FullRowSelect, something like:
Code:
 myDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
hope this helps

Age is a consequence of experience
 
Thanks

I couldn't do it like that as I'm using an old 2003 datagrid which doesn't have that property.

I did this instead:-

private void DataGrid_CurrentCellChanged(object sender, EventArgs e)
{
DataGrid.Select(DataGrid.CurrentRowIndex);
}

Seemed to do the trick.

Cheers
Spangeman

Thanks for your help though.
 
It was the (2005) bit that made me think it was the DGView. Glad you are sorted and thanks for the star :)

Age is a consequence of experience
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top