Populating Textbox in different form with DataGridView data

1

I'm trying to add data from one row of a DataGridView from one form to another by clicking on a "confirm button", but from searches I've done in other similar cases, the code is correct. Even so, I have no code return.

I'm doing the following:

Form2.TextBox1.Text = DataGridView1.CurrentRow.Cells(0).Value.ToString()

The data should appear in the text box of the other form when I click a button. What is wrong? The return I have is "nothing". It does not make any errors, but it does not work either.

    
asked by anonymous 12.03.2017 / 02:21

1 answer

0

Friend try to check if what you're getting from DataGridView1 is returning something!

Dim teste = DataGridView1.CurrentRow.Cells(0).Value.ToString()

With the test variable you can conclude that either the error is in the DataGridView1 or the error is when you are trying to pass the value to the Text Box of Form2. Then try passing the test value to the Text Box of Form2

Form2.TextBox1.Text = teste

I hope it helps or minimizes the problems!

    
13.09.2017 / 17:27