|
-
Jul 8th, 2010, 04:28 AM
#1
Thread Starter
Junior Member
Passing data from DGV to another form
Hi,
I have returned to a project I started a while ago. I have a small members database showing basic info (Title, Forename and Surname) in a data grid view with all data populated from a SQL database.
I have the dataset populated with all this info as well as other data through the use of relationships/foreign keys (Addresses and Telephone Numbers, etc)
I have tested the relationships using a simple form which shows the correct addresses, telephones, etc for each user as you navigate through it.
I now wish to show just the datagridview on form 1 which is read only with the row select set to full row (I have done all this so far). I have also set up a second form which displayes just the relationship data.
I want to be able to load the second form (with the address and telephone number data, etc) when the row is double clicked by the user. ie - if row 15 is double clicked on, then the second form should load the address and telephone number data for record 15.
I am having no luck right now and hope all has been explained ok?
-
Jul 8th, 2010, 05:08 AM
#2
Thread Starter
Junior Member
Re: Passing data from DGV to another form
Right after a little more research I have now placed this code into the DGV:
Code:
Private Sub UsersDataGridView_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles UsersDataGridView.CellContentDoubleClick
Dim UserRow As DataGridViewRow = UsersDataGridView.Rows(e.RowIndex)
Using dialogue As New UserEdit(UserRow)
dialogue.ShowDialog()
End Using
End Sub
Assuming I want to pass DataGridViewRow into the form UserEdit, what code would need to be put into the second form to allow the above to work?
-
Jul 8th, 2010, 10:01 AM
#3
Thread Starter
Junior Member
Re: Passing data from DGV to another form
Anyone know where to look for the code needed in Form2 to accept the input from Form1? I have been trawling the net for hours now and am no further forward
-
Jul 10th, 2010, 11:03 AM
#4
Hyperactive Member
Re: Passing data from DGV to another form
Put this code in the form receiving the DataGridViewRow:
vb Code:
Public Sub New(ByVal row As DataGridViewRow)
Me.InitializeComponent()
' You can then use the object row as necessary
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|