Results 1 to 5 of 5

Thread: Get DataGridView Row

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2010
    Posts
    33

    Get DataGridView Row

    Hi All,

    I have a datagridview. FullRowSelect property of datagridview has been set to False. So user only play with cell values.
    I need DataGridView Row using selected cell value.

    Can any one please help me how can it possible.

    Thankx
    Vijay

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Get DataGridView Row

    Firstly, not that "current" and "selected" mean different things in this context. "Current" means where the caret is currently located while "selected" means highlighted. There can only ever be one current row and one current cell at a time, while you can have multiple selected rows and cells, depending on the configuration.

    If you want the row containing the current cell then just use the CurrentRow property. If you want the rows containing the selected cells then loop through the SelectedCells collection and get the OwningRow of each one. Just note that that may contain duplicates if multiple cells in the same row are selected.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2010
    Posts
    33

    Re: Get DataGridView Row

    So, can u tell me how can i get the first row's cell value depending upon current cell index.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Get DataGridView Row

    You know about the CurrentRow. Like all rows, it has a Cells property that is a collection of cells. Each of those has a Value property.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2010
    Posts
    33

    Re: Get DataGridView Row

    Thankx, Yes I know the Current Row property. Thankx for pointing me on right track

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