Results 1 to 3 of 3

Thread: [RESOLVED] [2005] Get cell content from selected row in DataGridView

  1. #1

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Resolved [RESOLVED] [2005] Get cell content from selected row in DataGridView

    Hello.

    This is what I want to do:
    On DataGrid double click, I want to return the value of the 1st cell from the selected row. I've done this code but it doesn't work very well.

    Code:
        Private Sub DataGridView1_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentDoubleClick
            Me.TextArtigo.Text = Me.DataGridView1.Item(e.ColumnIndex, 1).Value
    
        End Sub
    Thank you.

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2005] Get cell content from selected row in DataGridView

    This should do it for you... Notice that I'm handling the CellDoubleClick event (so that even if the user doubleclicks outside of the actual content of the cell (but still within the cell's boundary), it still works)
    Code:
    Private Sub DataGridView1_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
            Me.TextArtigo.Text = Me.DataGridView1.Item(0, e.RowIndex).Value.ToString()
        End Sub

  3. #3

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Re: [2005] Get cell content from selected row in DataGridView

    Thank you.
    That work's pretty good!

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