CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2001
    Location
    Reykjavik, Iceland
    Posts
    46

    Question DataGrid, row select

    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...

  2. #2
    Join Date
    May 2002
    Location
    Belgium
    Posts
    9

    Re: DataGrid, row select

    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...

  3. #3
    Join Date
    May 2001
    Location
    Reykjavik, Iceland
    Posts
    46

    Cool

    thanx, that´s what I needed...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured