How do I find out which control has focus in Windows Forms?
You can use this to find by Control Name .
If DataGridView1.Name = Me.ActiveControl.Name Then TextBox1.Visible = True Else TextBox1.Visible = False End If