Click here to Skip to main content
15,908,264 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have form 4 & form 5 both having several textboxes.

On form4, all the textbox information inserted should go to the datagridview using the following code;

Private Sub Form4_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        table.Columns.Add("Header1", Type.GetType("System.String"))


Then when clicking a button normally on a single form, it would execute the following code which would populated the datagridview1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        table.Rows.Add(TextBox1.Text)


My question is, if instead the button shows form5 and i have textboxes there which need populating to a single datagridview how would i achieve this.

I have tried the following code but no luck:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    table.Rows.Add(Form4.TextBox1.Text)


The idea is that information inserted into textbox1 from form4 and then textbox 1 on form5 all populates to a single datagridview.

What I have tried:

<pre>Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    table.Rows.Add(Form4.TextBox1.Text)
Posted
Updated 17-Apr-17 4:07am
Comments
[no name] 17-Apr-17 8:19am    
What the heck does "no luck" mean?
"how would i achieve this", oh I don't know. Did you try passing the data to "Form5"?

Seriously stop using these type of names for your forms and controls. Give them meaningful names.
caf20012 17-Apr-17 8:32am    
Hi,

Thank you for the response! You'll have to be patient with me considering i have been using visual studios for 2 days now.

Please can you elaborate on passing the date to form5?
[no name] 17-Apr-17 8:52am    
"passing the date to form5", elaborate what? Pass the data to the form just like you pass data to a function. It's the same thing.

1 solution

@OriginalGriff has written a series of Tips on how to pass information between forms. Here is a link to the first one Transferring information between two forms, Part 1: Parent to Child[^] - there are links to the others in the Contents of that Tip
 
Share this answer
 

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