Results 1 to 2 of 2

Thread: [RESOLVED] Get value from DataGridView on form load

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2013
    Posts
    44

    Resolved [RESOLVED] Get value from DataGridView on form load

    I am trying to get a value fro a DataGridView 'DGV' when my winform loads ie, Forms2_load. DGV is bound and I am using the code below to Fill the DGV.

    My question is, how do I get a value from 'DGV' without any user intervention, just when the form loads. I have FullRowSelect as default in properties and notice that when the form first loads the first entry in DGV is highlighted 'Blue'. Does this mean that the first row is selected by default? I tried a for next loop on the form load event, but no message pops up. Can someone please help with this. Thanks

    Code:
    Me.CustomersTableAdapter.Fill(Me.StorageDataSet1.Customers)
    
    Dim values As String
    
        For Each RW As DataGridViewRow In DGV.Rows
            'Send the first cell value into messagebox'
            values = RW.Cells(0).Value.ToString
    
        Next
    
    MessageBox.Show(values)

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: [RESOLVED] Get value from DataGridView on form load

    I see this is marked resolved although there have been no replies. Is it (resolved, that is)? In which case perhaps you'd like to add some details of what you learnt to aid others?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

Tags for this Thread

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