473,387 Members | 1,495 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,387 software developers and data experts.

Is there a TabPageRemoved event in C#?

I am trying to trigger an event when a tab page is removed from my tabControl in C#. I have found a ControlRemoved event and implemented it but when I remove the first tab from my tabcontrol the event is not trigged. The event works for all other tabs being removed (including the tab that would not trigger the event the first time)..

Expand|Select|Wrap|Line Numbers
  1. tabControl1.ControlRemoved +=new ControlEventHandler(tabControl1_ControlRemoved);
Expand|Select|Wrap|Line Numbers
  1. private void tabControl1_ControlRemoved(object sender, ControlEventArgs e)
  2.         {
  3.             MessageBox.Show("Tab removed!");
  4.         }
When I trace through my program, the event handler is reached but it doesn't trigger anything.

Can anyone figure out what's going on here?
Mar 24 '11 #1
1 2529
GaryTexmo
1,501 Expert 1GB
...but when I remove the first tab from my tabcontrol the event is not trigged. The event works for all other tabs being removed (including the tab that would not trigger the event the first time)
I'm a bit confused about what's going on here. If you attached a listener to the ControlRemoved event on your tab control, the event should get fired every time a control is removed.

I'm actually quite confused by that last bit haha.

Anyway, I created a simple project and put a tab control on it with a bunch of pages. I created a button and put the following for its click event:

Expand|Select|Wrap|Line Numbers
  1.         private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             if (tabControl1.SelectedTab != null)
  4.                 tabControl1.TabPages.Remove(tabControl1.SelectedTab);
  5.         }
Then I made a listener for the ControlRemoved event with just a Console.WriteLine in it... as follows...

Expand|Select|Wrap|Line Numbers
  1.             TabPage senderTB = e.Control as TabPage;
  2.             if (senderTB != null)
  3.             {
  4.                 Console.WriteLine(string.Format("TabPage, {0} ({1}), has been removed.", senderTB.Text, senderTB.Name));
  5.             }
When I ran it, I got my console messages as expected and none were missed.

Is there more to your code that you're posting? Maybe you've got something else going on in there...?
Mar 25 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Andy Read | last post by:
Hello all, I have the requirement to produce source code that produces an object hierarchy. Example: Root | Folder 1
18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
8
by: Mark | last post by:
Hi, I'm looking for some ideas on how to build a very simple Event processing framework in my C++ app. Here is a quick background ... I'm building a multithreaded app in C++ (on Linux) that...
2
by: Alex Sedow | last post by:
Why interface-event-declaration does not support multiple declarators like event-declaration? Grammar from C# spec: variable-declarators: variable-declarator variable-declarators ","...
13
by: Charles Law | last post by:
Mr "yEaH rIgHt" posted the following link about a week ago in answer to my question about removing event handlers. > http://www.vbinfozine.com/t_bindevt.shtml Following on from that post, the...
12
by: Jack Russell | last post by:
My unstanding of all VB up to and including vb6 is that an event could not "interrupt" itself. For instance if you had a timer event containing a msgbox then you would only get one message. ...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
9
by: jeff | last post by:
New VB user...developer... Situation...simplified... - I want to wrap a pre and post event around a system generated where the pre-event will always execute before the system event and the...
19
by: Daniela Roman | last post by:
Hello, I try to fire an event under a button click event and maybe anybody can give a clue please. I have let's say a WEB grid with PageIndexChanged event: private void...
5
by: jaysonnward | last post by:
Hello All: I've recently been recreating some 'dropdown menus' for a website I manage. I'm writing all my event handlers into my .js file. I've got the coding to work in Firefox, but the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...

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.