tags:

views:

38

answers:

2

Hi,

I have TabControl. I added it to tabpages. To one of them(tpTags) I dynamically add usercontrol tagsModule. When I'll click at tpTags I wanna to call method on tagsModule BindData

NEW CODE: 
  TabPage tpTags = new TabPage();
    tabControl1.TabPages.Add(tpTags);
    ...setting properties...
   TagsModule tagsModule = newTagsModule(_countryCode, ObjectType.Country);
 tpTags.Select() = tpTags.BindData(); //**How do it ??**

    tpTags.Controls.Add(tagsModule);

It could be: "how do I set an event that triggers when this tab is selected?"

+1  A: 

If you mean "how do I make this the current tab", then:

tabs.SelectedTab = tpTags;

If you mean "how do I respond when this tab is selected", then look at the tpTags.SelectedIndexChanged event (you don't necessarily need to care about the index when handling this event - you can just check tabs.SelectedTab again).

Marc Gravell
Could you like at updated code ?I need your help
+2  A: 

You have to wire up the delegate to the event like this:

tabControl1.SelectedIndexChanged += new EventHandler(this.tabControl1_SelectedIndexChanged);

Now you can put all your code inside this method

private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
{
    if(TabControl1.SelectedTab == tpTags)
    {
        // BindData();
    }
}

BindData() runs whenever your tabPage 'tpTags' is selected. If you want only for the first time, set a flag.

Veer
i don't understand your question now. Can you elaborate it?
Veer
I have TabControl. I added to it tabpages. To one of them(tpTags) I dynamically add usercontrol tagsModule. When I'll click at tpTags I wanna to call method on tagsModule BindData