Well I had a solution, but I want to reduce how much coding I do ('cause I'm no good at coding).
Basically I have a windows applicaton with a bunch of forms, and on each form is a tab control, and on each tab control is a bunch tabs all with different datagridviews, and the number keeps growing!
I found some code that nicely prints the datagridviews, and I wanted to be able to set "DataGridView1" (which is declared as "Private DataGridView1 As DataGridView") with the current datagridview the user is on.
From the question I previously asked, I was able to get the name of the SelectedTab from the TabControl, which is the active control (the datagridview that is on the SelectedTab is NOT the active control as was suggested in the related question). Then I have an "if" statement to set "DataGridView1":
Dim MyActiveTab As String = TabControl1.SelectedTab.Name
If MyActiveTab = "TabPage1" Then
DataGridView1 = PartnershipsDataGridView
ElseIf MyActiveTab = "TabPage2" Then
DataGridView1 = PartnersDataGridView
ElseIf MyActiveTab = "TabPage3" Then
etc, etc. and so on.
I do this because I know the name of the datagridview on each tab page. Problem is I don't want to do this for every datagridview I add on every form ('cause I'm adding them all the time). Any help/thoughts would be much appreciated.