events (tabs)

  • Thread starter Thread starter csharpula csharp
  • Start date Start date
C

csharpula csharp

Hello,

I have a form which contains few other forms in tab view.

I want to catch the event of moving from one tab to another. Can I do it
on the tab sub form itself?(I mean to catch the event of moving from
this tab to anoter tab) If I can,how?

Thanks!
 
I have a form which contains few other forms in tab view.

Please explain this further, as, to the best of my knowledge, it is
impossible to make a form (that is, an instance of class Form, or any
subclass of that) a child of any other control.

Do you, perhaps, mean a custom user control? I will assume that you do
for the rest of the post.
I want to catch the event of moving from one tab to another. Can I do it
on the tab sub form itself?(I mean to catch the event of moving from
this tab to anoter tab) If I can,how?

You can get the TabPage your user control is in via its Parent
property (appropriately cast). From there, you can of course get to
the TabControl, and subscribe to the appropriate events.

Note, however, that this introduces tight coupling between your
control and TabPage (since now it can only live inside a TabPage). If
the sole purpose of your controls is to be hosted inside tab pages in
a specific form, that's probably okay. If not, a redesign may be due.

Also, remember to unsubscribe those event handlers in your control
when the value your Parent property changes! (otherwise you'll get get
memory leaks)
 
Hello,

I have a form which contains few other forms in tab view.

I want to catch the event of moving from one tab to another. Can I do it
on the tab sub form itself?(I mean to catch the event of moving from
this tab to anoter tab) If I can,how?

Thanks!

not sure when you talk of subform what you mean with that.
The TabControl has a SelectedIndexChanged event, you have to handle it.
 
Back
Top