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
}
}
ご覧のとおり、私のWinform(タブページ上)を閉じると、データを送り返してtab_indexを修正する必要があります。 私はWinformとタブページの両方を閉じることができますが、データの送り返しには苦労しています。 私はchildFormからparentFormにデータを返す方法を知っていますが、ここでの状況は少し異なります。Winformからタブページにデータを戻す方法
私はタブページからクラスのインデックスを宣言しようとしました。 そして、私はwinFormを閉じるたびにインデックスを修正しようとしました。 winFormでは、私は Form2 x =新しいForm2(); x.tab_index--; ; しかし、うまくいきません、tab_indexは正しい値ではなく、フォームを閉じる前に毎回0です。 –
はい、いつでも 'new'を呼び出すと、新しい参照をインスタンス化します。 'tabControl1.Parent.tab_index - 'のようなことをする必要があります –