473,804 Members | 3,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("TabPag e4");
this.tabControl 1.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.Dispos e();
tabPage3.Dispos e();

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 1688
This should be relatively simple. Try using this:

if (this.tabContro l1.TabPages.Cou nt > 0)
{
this.tabControl 1.TabPages.Remo veAt(this.tabCo ntrol1.Selected Index);
}

"JG" <nospam> wrote in message news:eK******** ******@tk2msftn gp13.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("TabPag e4");
this.tabControl 1.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.Dispos e();
tabPage3.Dispos e();

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
3549
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 about the newbie trivial question -- David Lindsay anti spam in force use reply to address
32
3212
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
1305
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? http://s22.yousendit.com/d.aspx?id=0FJE4MQAJUPW20FJCSFIEQ6VES Is thre any one who k help me with it? do email me at bb32_fong@yahoo.com.sg
1
1328
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 button, append a table of work descriptions (a template) to a table of client work descriptions, which I understand how to do. What I can't understand is how to tie the work descriptions to the
2
1070
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 to know when the tabpagex is already added ? Stan
0
806
by: Ninio | last post by:
do not read please, this was a double post by accident sorry about that
4
1956
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
9579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10571
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10326
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10317
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9143
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.