Click here to Skip to main content
12,690,140 members (31,113 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
Hello ppl, I need some help.

I have one form that contains emtpy Tab control, also a toolbar button which creates an empty tab and then loads user control into that new tab. On the Usercontrol i have CLOSE button, and I need to close that specific (selected) tab. Can someone help me with this? Thanx in advance.
Posted 13-Nov-12 1:48am
Bawg280

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I believe what you will need is to use a delegate to pass over the event.

Events and Delegates Simplified[^]

Code project article already exists to help with that thanks to Meysam Mahfouzi[^]
  Permalink  
Comments
onurag19 13-Nov-12 7:12am
   
Nice One:)
Rob@Love2Code 13-Nov-12 7:22am
   
Cheers, the articles exist, but sometimes people don't know what to search for :)
Hope this helps them.
Bawg 13-Nov-12 7:28am
   
thanx for advice, i was searching a lot before I posted this question. for an ex-vb6 user, this looks like nightmare :) it still does :)

edit : I forgot to say that I just need to fire some event, not to pass any data, I'm not telling which tab need to be closed, just to close currently selected.
Rob@Love2Code 13-Nov-12 7:40am
   
The reason I suggest using the delegate event, is you set it up so that when the user clicks the close button on the Usercontrol, it will first check to see if the delegate event isnt null, and if it isnt, you can then call the delegate event.
From your form you would then have added that delegate event to call an event on that form which you could then add the Close Selected tab.

Does that make sense?
Its almost as if you are just passing back to the main the fact the event occurred (if you did need to pass data, you could).
Bawg 13-Nov-12 14:56pm
   
Thank you all. I'm digging it right now.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170117.1 | Last Updated 13 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100