I am working with a form and I need to know what the active control is. I am using AddHandler. So far I am using something like this
AddHandler txtBox.GotFocus, AddressOf TextBox_GotFocus
Private Sub TextBox_GotFocus()
_form.ActiveControl.BackColor = Highlight
I wrote a sample version outside of the main application and things went well. The controls on the form are standard windows syncfusion, and some usercontrols. All of these sit on an image panel divided up on a tabsheet.
I realise this is a bit of a soup in terms of form content, but that is what I have to work with. I supect I might be able to use an alternative approach to ActiveControl but I am not aware of it.
As a foot note the _form is a by reference to the form because this code is in a class, the intent is to create a generic branding class to enable brand format to be applied over the whole application. Also this is a winforms development.