473,394 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Please help me with this TabPage question...

JG
Hi,

I have a windows form with a TabControl on it. It has 3 tabpages on it. I
have also coded a button that is supposed to 'add' a new tabpage.

The code in that clicked event looks like this:

tabPage tpNew = new TabPage("TabPage4");
this.tabControl1.TabPages.Add(tpNew);
tpNew.Controls.Add(this.label1);

No problem. It works just fine and adds the new tabpage to tabControl1. Note
in that tabpage that a label is also added. This too works just fine.

Now my question is this: how do I despose of that 'new' tabpage. I have
coded another button on my test winform and it desposes of the tabpages on
tabControl. It looks something like this:

tabPage2.Dispose();
tabPage3.Dispose();

Now, how do I dispose of the tabpage that I have added in the code above? I
have tried several things, but cannot get that one to go away...

Any help would be greately appreciated. Regards,
joe
Nov 15 '05 #1
2 1669
This should be relatively simple. Try using this:

if (this.tabControl1.TabPages.Count > 0)
{
this.tabControl1.TabPages.RemoveAt(this.tabControl 1.SelectedIndex);
}

"JG" <nospam> wrote in message news:eK**************@tk2msftngp13.phx.gbl...
Hi,

I have a windows form with a TabControl on it. It has 3 tabpages on it. I
have also coded a button that is supposed to 'add' a new tabpage.

The code in that clicked event looks like this:

tabPage tpNew = new TabPage("TabPage4");
this.tabControl1.TabPages.Add(tpNew);
tpNew.Controls.Add(this.label1);

No problem. It works just fine and adds the new tabpage to tabControl1. Note in that tabpage that a label is also added. This too works just fine.

Now my question is this: how do I despose of that 'new' tabpage. I have
coded another button on my test winform and it desposes of the tabpages on
tabControl. It looks something like this:

tabPage2.Dispose();
tabPage3.Dispose();

Now, how do I dispose of the tabpage that I have added in the code above? I have tried several things, but cannot get that one to go away...

Any help would be greately appreciated. Regards,
joe

Nov 15 '05 #2
JG
Thank you very much... Can't see the forest for the trees...

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: David Lindsay | last post by:
I want to put date and time on my web page, and to be sure it tracks the BST/ GMT changes. Can anyone help me, I have gone back in my historic file for quite a while and not found anything. Sorry...
32
by: Christopher Benson-Manica | last post by:
Is the following code legal, moral, and advisable? #include <iostream> class A { private: int a; public: A() : a(42) {}
5
by: bojiokia | last post by:
I have started school for just 3 weeks,and totally new to c++,what i learn is just cin n cout and i received this project, omg, i am totally lost in what the question wanted me to input? ...
1
by: Michael J. Savage | last post by:
Hi All, I posted yesterday re appending a table to another but it seems I was asking the wrong question. What I'm trying to do is open a client information table and, with a click of a...
2
by: Stan Sainte-Rose | last post by:
Hi guys I have a little problem with the tabcontrol. I add and remove tabpage using the following methods : TabControl1.Controls.Add(tabpagex) TabControl1.Controle.Remove(tapagex) But how...
0
by: Ninio | last post by:
do not read please, this was a double post by accident sorry about that
4
by: Jim Rutledge | last post by:
ok ok , anyone know anything on this tough question? How do you determine the length in seconds that a midi file is , or any audio file for that matter ?
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.