Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello there, As i am a relative new programmer i encouter a problem that i need your help fore. I have two forms. Form 1 is called "Projectnameform" and contains address data in a gridview. Form2 is called "ProjectDetailsForm" where i have shown projectDetails.

All the data is stored in a MS Sql database externaly. I use a Tableadapter, Dataset and Bindingsource on both forms to fill them with data.

Can you please show me how i can select a row on the "Projectname" (form1) and by a buttonClick event it only shows the related details of the selected row in form1 by the projectnameid that i have created in both forms.

Your help is very much appreciated as im struggeling with this for the pas 5 day's now.

Regards
Marc

What I have tried:

I tried to select the row in form1 and to pass it to an unvisible label and then read the labeltext to identify the selected row of form1. I tried to bind the bindingsource and pass the value.
Posted
Updated 27-Feb-17 8:15am

There is a series of tips here on CodeProject by OriginalGriff that should help you pass the information between forms.

Here's the first one - Transferring information between two forms, Part 1: Parent to Child[^] - links to the others are in that article.
 
Share this answer
 
Comments
Maciej Los 27-Feb-17 13:23pm    
5ed!
In addition to solution 1 by CHill60, i'd like to provide another interesting article: Passing Data Between Forms - VB.NET Tutorials | Dream.In.Code[^]
 
Share this answer
 
Comments
Member 11525501 27-Feb-17 16:05pm    
Thanks, but this is not what im trying to achieve. Im looking for a way to read the selected row's PrimairyKey Value (not visible in the Grid) on form 1 and see the related rows in form2 as the details form. I keep reading about binding the bindingsource, but i have no clue how to start doing this. Tnx again for your help.
CHill60 28-Feb-17 8:00am    
In other words, you have two problems. Problem 1 - how to get data from a row in the control that is not visible. You need to update your question with details of which platform you are using (WinForm, WPF, ASP) and which Grid you are using.
Problem 2: How to pass that information between the forms.
The solutions offered (1 and 2) solve Problem 2 for you.
We can't offer you a solution for Problem 1 until you provide the missing information. You can use Improve question link to get the extra information into your question, and if you reply to this comment (using the  Reply  button) then we'll be notified to come back and have another look
Maciej Los 28-Feb-17 8:47am    
Well said!
CHill60 28-Feb-17 8:58am    
5'd by the way. The fact the OP doesn't realise they need your link doesn't detract from the fact it is more relevant than my link :-)
Maciej Los 28-Feb-17 9:40am    
Thank you, Caroline. We haven't got to go into bragging match in which link is more relevant than other. Both are worth 5 ;)
Cheers,
Maciej

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900