Getting the TabPage of a control...



I am trying to find the tab page a certain control is on.
Basically I'm using the MSRDP ActiveX Control. On the "disconnect" event, I want to then remove the TabPage that the relevant RDP session lived in. So, I have the following code:

void _tsClient_OnDisconnected(object sender, AxMSTSCLib.IMsTscAxEvents_OnDisconnectedEvent e)
{
AxMSTSCLib.AxMsRdpClient6NotSafeForScripting _dClient = (AxMSTSCLib.AxMsRdpClient6NotSafeForScripting)sender;
//get container.
TabPage _clientTab = (TabPage)_dClient.Container;
tabSessions.TabPages.Remove(_clientTab);
}

However, _clientTab is always null... I saw ContainingControl, however that won't compile as it says it cannot convert Type "System.Windows.Forms.ContainerControl' to 'System.Windows.Forms.TabPage'.

Any ideas?

.


Loading