How to pass data back from Winform to tabpage

Go To StackoverFlow.com

0

 if (!existed_channel.Contains(channel_name))
            {

                if (x)
                {
                    tabpagex.BackColor = Color.Ivory;

                    tabControl1.TabPages.Add(tabpagex);

                    client_chat c = new client_chat(channel_name, owner);   //Here the client_chat is my Winform that do all the chatting thing.
                    c.TopLevel = false;
                    c.Visible = true;
                    c.BackColor = Color.Ivory;
                    c.FormBorderStyle = FormBorderStyle.None;
                    c.Dock = DockStyle.Fill;
                    tabControl1.TabPages[tab_index].Controls.Add(c);   //Here i fill up the tabpage with client_chat winform

                    tab_index++;                        //Increment the index everytime i add an tabpage.
                    existed_channel.Add(channel_name);  //Add the name of the page to an arraylist, to make sure everytime there is no duplicate page
                }
            }

As you can see, when i close one of my Winform(on the tabpage), i have to send back data and modify the tab_index. I am able to close both Winform and tabpage, but struggling how to send the data back. I know how to send back data from childForm to parentForm, but the situation here is little different.

2012-04-04 01:35
by qwr qwr


0

You could use a global property on the parent that all controls have access to

2012-04-04 01:37
by Justin Pihony
I tried to declare the index in the class that the tabpage from. And i tried to modify the index everytime i close a winForm. In the winForm, i do Form2 x = new Form2(); x.tab_index--;

But it doesn't work, the tab_index is not the right value, its 0 every time before i close the form - qwr qwr 2012-04-04 01:45

Yes, anytime you call new, it instantiates a new reference. You need to do something like tabControl1.Parent.tab_index--Justin Pihony 2012-04-04 02:14