424,045 Members | 1,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,045 IT Pros & Developers. It's quick & easy.

How can I catch tab change on a TabControl?

P: n/a
I would like to catch the tab change before it occurs. There is a
SelectedIndexChanged event to catch the change after it occurs. How do I
catch when the user clicks on a tab, but before the TabPage changes?

Is there anything like the TCN_SELCHANGING notification?

TIA

David Rose

Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Nicholas,

Thanks. That works fine.

I was hoping that there would be an easier way, but I guess that for some
reason that event is not handled in .NET.

David
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote
in message news:OK**************@TK2MSFTNGP09.phx.gbl...
David,

You should be able to hook into the windows procedure of the parent of
the tab control and catch that notification. You just have to override the WndProc method on that container.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"David Rose" <da***@silverswitch.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I would like to catch the tab change before it occurs. There is a
SelectedIndexChanged event to catch the change after it occurs. How do I catch when the user clicks on a tab, but before the TabPage changes?

Is there anything like the TCN_SELCHANGING notification?

TIA

David Rose


Nov 15 '05 #2

P: n/a
You could use the MouseDown event to determine that the user has clicked on
the tab contol and then check to see what tab was clicked.

Mike Shane
MST Associates

"David Rose" <da***@silverswitch.net> wrote in message
news:uJ**************@TK2MSFTNGP09.phx.gbl...
Nicholas,

Thanks. That works fine.

I was hoping that there would be an easier way, but I guess that for some
reason that event is not handled in .NET.

David
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote in message news:OK**************@TK2MSFTNGP09.phx.gbl...
David,

You should be able to hook into the windows procedure of the parent of
the tab control and catch that notification. You just have to override the
WndProc method on that container.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"David Rose" <da***@silverswitch.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I would like to catch the tab change before it occurs. There is a
SelectedIndexChanged event to catch the change after it occurs. How

do I catch when the user clicks on a tab, but before the TabPage changes?

Is there anything like the TCN_SELCHANGING notification?

TIA

David Rose



Nov 15 '05 #3

P: n/a
Mike,

That was the first thing I tried. For some reason that event fires after
the SelectedIndexChanged event for the TabControl. I am not sure how
Windows Forms routes events. Know a good source of information on Forms
event routing?

Handling the WM_NOTIFY message works as expected.

David
"Mike Shane" <mi********@msta.com> wrote in message
news:Om**************@TK2MSFTNGP09.phx.gbl...
You could use the MouseDown event to determine that the user has clicked on the tab contol and then check to see what tab was clicked.

Mike Shane
MST Associates

"David Rose" <da***@silverswitch.net> wrote in message
news:uJ**************@TK2MSFTNGP09.phx.gbl...
Nicholas,

Thanks. That works fine.

I was hoping that there would be an easier way, but I guess that for some
reason that event is not handled in .NET.

David
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote
in message news:OK**************@TK2MSFTNGP09.phx.gbl...
David,

You should be able to hook into the windows procedure of the
parent of the tab control and catch that notification. You just have to

override the
WndProc method on that container.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"David Rose" <da***@silverswitch.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> I would like to catch the tab change before it occurs. There is a
> SelectedIndexChanged event to catch the change after it occurs. How

do
I
> catch when the user clicks on a tab, but before the TabPage changes?
>
> Is there anything like the TCN_SELCHANGING notification?
>
> TIA
>
> David Rose
>
>
>



Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.