CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Datagrid

  1. #1
    Join Date
    Mar 2003
    Location
    Traverse City, MI
    Posts
    24

    Datagrid

    Hey All,

    Is there a simple way to get a collection of rows out of the datagrid. I know you can use the isSelected method of the datagrid control, but I want to get the text value out of a certain column of the selected row. Im new to the datagrid control, so any help would be appreciated.


    Thanks,
    Ryan

  2. #2
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    from MSDN,

    private void PrintCellValues(DataGrid myGrid){
    int iRow;
    int iCol;
    DataTable myTable;
    // Assumes the DataGrid is bound to a DataTable.
    myTable = (DataTable) dataGrid1.DataSource;
    for(iRow = 0;iRow < myTable.Rows.Count ;iRow++) {
    for(iCol = 0;iCol < myTable.Columns.Count ;iCol++) {
    Console.WriteLine(myGrid[iRow, iCol]);
    }
    }
    }


    -Paresh
    - Software Architect

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