Click to See Complete Forum and Search --> : DataGrid, row select


Mundi
June 4th, 2002, 04:01 AM
Hi, I have a datagrid on my form and I want to be able to click on a row in that datagrid so the whole row is selected, not just one cell.

I allso want to retrieve the value of the first column in the selected row.

Anyone know how to do this or where to find good info on DataGrid? I think I have read just about everything in the help in visual studio...

on1ami
June 4th, 2002, 08:22 AM
Hey Mundi,

I do it this way:

int Row = dataGridGebruikers.CurrentRowIndex;
DataGridCell myCell = new DataGridCell();
// Use and arbitrary cell.
myCell.RowNumber = Row;
myCell.ColumnNumber = 0;
string selectedUserID = dataGridGebruikers[myCell].ToString().Trim() ;
dataGridGebruikers.Select(Row);

The selectedUserID I use to construct my SQL command for future use.

Consernating the good info on DataGrid, it's all in the help file and in MSDN just you have to know what you're looking after, there is noting like a course on it. Many information I have found in "ADO.NET Step by Step" by "Rebecca Riordan" an edition of Microsoft press

Geetings
Jean Paul



Originally posted by Mundi
Hi, I have a datagrid on my form and I want to be able to click on a row in that datagrid so the whole row is selected, not just one cell.

I allso want to retrieve the value of the first column in the selected row.

Anyone know how to do this or where to find good info on DataGrid? I think I have read just about everything in the help in visual studio...

Mundi
June 4th, 2002, 08:30 AM
thanx, thatīs what I needed... :cool: