I have a TabControl
to which the user can add tab pages.
I am trying to attach some events to it such as: MouseEnter
, MouseLeave
, MouseClick
, But it seems the these events are not firing at all, they only fire when I attach them to the TabControl
itself, but this is not what I need.
What is the problem with attaching events to a tab control tab page ?
Here is my latest attempt to attach these event from my code:
private void customerTabCtrl_ControlAdded(object sender, ControlEventArgs e)
{
TCTabPage tctab = (TCTabPage)e.Control; // Option A
TCTabPage tctab = (TCTabPage)customerTabCtrl.Controls[customerTabCtrl.Controls.Count - 1]; //Option B
tctab.MouseEnter += new EventHandler(tctab_MouseEnter);
tctab.MouseLeave += new EventHandler(tctab_MouseLeave);
}