Click here to Skip to main content
15,915,600 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: DataSet writing errors with code Pin
Quecumber2564-Jun-07 10:17
Quecumber2564-Jun-07 10:17 
Questionvb.net Pin
srinivassam4-Jun-07 2:01
srinivassam4-Jun-07 2:01 
AnswerRe: vb.net Pin
kubben4-Jun-07 2:26
kubben4-Jun-07 2:26 
AnswerRe: vb.net Pin
Christian Graus4-Jun-07 2:52
protectorChristian Graus4-Jun-07 2:52 
Questiona question about row-index Pin
vbbeg4-Jun-07 1:47
vbbeg4-Jun-07 1:47 
AnswerRe: a question about row-index Pin
Dave Kreskowiak4-Jun-07 4:06
mveDave Kreskowiak4-Jun-07 4:06 
GeneralRe: a question about row-index Pin
vbbeg4-Jun-07 4:56
vbbeg4-Jun-07 4:56 
GeneralRe: a question about row-index Pin
Dave Kreskowiak4-Jun-07 6:32
mveDave Kreskowiak4-Jun-07 6:32 
vbbeg wrote:
what i intend to do is retrieve further data from table based on the select DGV row.


OK. Then you're looking for the SelectedRows or SelectedCells. They return a DataGridViewRow and DataGridViewCell respectively. These will contain the data that the user clicked on, regardless if the DGV is bound or not, sorted or not.
Private Sub DGV1_SelectionChanged(blah, blah) Handles DGV1.SelectionChanged
    For Each row As DataGridViewRow In DGV1.SelectedRows
        For Each cell As DataGridViewCell In row.Cells
            Debug.Write(cell.FormattedValue.ToString() & " | ")
        Next
        Debug.WriteLine(String.Empty)
    Next
End Sub

Each DataGridViewCell object knows which DataGridViewRow contains it, through its OwningRow property. If the user clicks on any cell, the OwningRow property of that cell will give you the DataGridViewRow that the user clicked in. Using that, you can get the ID column of the row and use that value any way you want.
For Each cell As DataGridViewCell In DGV1.SelectedSells
    Debug.WriteLine(String.Format("Cell Data: {0}    Parent Row ID: {1}", _
        cell.FormattedValue.ToString, _
        cell.OwningRow.Cells("IDColumnName").FormattedValue.ToString))
Next





A guide to posting questions on CodeProject[^]

Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007


GeneralRe: a question about row-index Pin
vbbeg4-Jun-07 7:11
vbbeg4-Jun-07 7:11 
GeneralRe: a question about row-index Pin
Dave Kreskowiak4-Jun-07 8:09
mveDave Kreskowiak4-Jun-07 8:09 
GeneralRe: a question about row-index Pin
Dave Kreskowiak4-Jun-07 13:33
mveDave Kreskowiak4-Jun-07 13:33 
GeneralRe: a question about row-index Pin
vbbeg4-Jun-07 17:24
vbbeg4-Jun-07 17:24 
QuestionProblem in adding dll files Pin
Nanda16054-Jun-07 0:59
Nanda16054-Jun-07 0:59 
AnswerRe: Problem in adding dll files Pin
WhiteGirl234-Jun-07 2:07
WhiteGirl234-Jun-07 2:07 
GeneralRe: Problem in adding dll files Pin
Nanda16054-Jun-07 2:17
Nanda16054-Jun-07 2:17 
GeneralRe: Problem in adding dll files Pin
Dave Kreskowiak4-Jun-07 4:05
mveDave Kreskowiak4-Jun-07 4:05 
Questionhelp! Pin
daredevil_beware164-Jun-07 0:55
daredevil_beware164-Jun-07 0:55 
AnswerRe: help! Pin
Christian Graus4-Jun-07 1:47
protectorChristian Graus4-Jun-07 1:47 
GeneralRe: help! Pin
daredevil_beware164-Jun-07 1:51
daredevil_beware164-Jun-07 1:51 
GeneralRe: help! Pin
Christian Graus4-Jun-07 2:54
protectorChristian Graus4-Jun-07 2:54 
GeneralRe: help! Pin
Sathesh Sakthivel4-Jun-07 3:05
Sathesh Sakthivel4-Jun-07 3:05 
QuestionRe: help! Pin
Sonia Gupta4-Jun-07 2:00
Sonia Gupta4-Jun-07 2:00 
AnswerRe: help! Pin
Sathesh Sakthivel4-Jun-07 3:21
Sathesh Sakthivel4-Jun-07 3:21 
AnswerRe: help! Pin
daredevil_beware164-Jun-07 2:58
daredevil_beware164-Jun-07 2:58 
GeneralRe: help! Pin
Sathesh Sakthivel4-Jun-07 3:07
Sathesh Sakthivel4-Jun-07 3:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.