This is my code:
List<TabPage> _tpList = new List<TabPage>();
int _iTabCount = 0;
TabPage CreateNewTab(string sTitle)
{
TabPage t = new TabPage();
t.BackColor = Color.White;
t.Text = sTitle;
_tpList.Add(t);
this.Tab.Controls.Add(_tpList[_iTabCount]);
_iTabCount++;
return _tpList[_iTabCount - 1];
}
I want to handle the Click Event of the one of the Control in List _tpList.
Is this possible?
You could add your event handler just after the creation of the tabPage
and add code like this:
eventually you could use the Tag property or the Name property of the TabPage to set an unique identifier for the page, so you could do a better check on the tabPage1_Click to discover the actual page clicked.
However, I wish to point that the best way to know which tabpage is active on a tab control, is by handling the Selected event on the tab control itself. That event has a TabControlEventArgs containing the current selected tabpage.