CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2003
    Location
    Toronto
    Posts
    805

    getting column value from DataGrid

    I have a data grid named

    dgMedical. I need to get the value of the 2nd column
    to display in my code. Any help.

    is it like
    dgMedical.select(1); ?

    thanks

  2. #2
    Join Date
    May 2002
    Location
    Hyderabad
    Posts
    76
    Hi,
    U can use
    DataGrid1.Items[selectedItem].Cells[1].Text to get the text of a particular cell in the selected row.

    regards,
    Ashish Sheth

  3. #3
    Join Date
    Jul 2003
    Location
    Linz,Austria
    Posts
    48
    hi,

    another thing you can use is this:

    string str = dataGrid1[int rowIndex, int columnIndex].ToString();

    or a like i did few days ago:
    if you use a mouseklick to select you can do this:
    add the

    "CurrentCellChanged(object sender,System.EventArgs e)"

    message and in the body of it you only need

    "string str = dataGrid1[dataGrid1.CurrentCell].ToString().Trim();"



    blue skies

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