updating a form with datagridview

lional

Member
Joined
Apr 10, 2012
Messages
16
Programming Experience
Beginner
Hi
I am very new to vb writing my first VB app.
I have a form showing certain fields from a SQL table using datagridview. This section is working fine.
What I want to do now is based on the record selected in the datagridview, when a button is clicked, all the info is displayed on another form for that particular record.
I have created the second form but the data that gets pulled through is always the first record in the database table and not the record selected in the datagridview.
How do I develop it that when the button is pressed it pulls through the data for the highlighted record in the datagridview to another form.

Thanks

Lional
 
If you are not already, retrieve the data from the database into a DataTable, bind that to a BindingSource and then bind that to the grid. You can then get the record currently selected in the grid from the Current property of the BindingSource.
 
If you are not already, retrieve the data from the database into a DataTable, bind that to a BindingSource and then bind that to the grid. You can then get the record currently selected in the grid from the Current property of the BindingSource.

I am using VB 2010 and I am not sure how to retrieve the data into a DataTable. I have been doing self study but as I found out the litreture that I have has a very limited database chapter. Is it the DataSet control.

Help would be greatly appreciated.
 
I am using VB 2010 and I am not sure how to retrieve the data into a DataTable. I have been doing self study but as I found out the litreture that I have has a very limited database chapter. Is it the DataSet control.

Help would be greatly appreciated.

Ok all I need to know now is how to set the current property in teh BindingSource and is it done on the grid form or the second form

thanks
 
You don't SET it. It is set automatically when the user selects a row in the grid. You GET the current record from the property, in the form of a DataRowView. A DataRowView is basically the same as a DataRow, so you can get field values by column name or index.
 
Back
Top