Easy fix: You can access a control on Form1 directly from Form2
So if you have DataGridView1 on Form1, in the Form2 code you can access it by using Form1.DataGridView1
Note: this is not a good design, because you are tightly coupling your two forms, you would be better to pass a reference to a DataGridView into Form2 rather than updating it directly
in the Constructor of Form2 force it to pass your reference:
Public Class Form2
Private _dgv As DataGridView
Public Sub New(dgv As DataGridView)
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
'ensure we have a value object
If dgv Is Nothing Then Throw New ArgumentNullException("DataGridView")
_dgv = dgv
End Sub
Private Sub frmRibbonTest_Resize(sender As Object, e As EventArgs) Handles Me.Resize
Dim rect = RibbonControl1.ClientRectangle
DataGridView1.Location = New Point(rect.X, rect.Y)
DataGridView1.Height = rect.Height
DataGridView1.Width = rect.Width
End Sub
End Class
Then when you create form2 from form1, use your reference like this:
Dim f2 = New Form2(Me.DataGridView1)
f2.Show()
module?