Suppose I have two forms i.e Form1 and Form2. Form1 contains dynamically created DataGridView control and Form2 contains two Textbox controls (Textbox1 and Textbox2) and a Button control.
When I DoubleClick on the DataGridView's cell it will open Form2 and the data from current selected cell passes to Form2's Textbox1
Here is the code:
I Added a handlear to my dynamically created DatagridView like this:
AddHandler dg.CellMouseDoubleClick, AddressOf dg_DataGridEdit
Private Sub dg_DataGridEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs)
Dim dgView As DataGridView = DirectCast(sender, DataGridView)
Form2.TextBox1.Text = dgView.CurrentCell.Value.ToString()
Form2.ShowDialog()
End Sub
When i click on the button from Form2, the value of current selected cell will change like TextBox2 from Form2 has. But the problem is i can't use the code from button1 from From2 like
Form1.dgView.CurrentCell.Value = TextBox2.Text
How can i pass value from textbox2 to current selected cell?