472,119 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

How can I catch tab change on a TabControl?

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
3 49286
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
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
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.

Similar topics

5 posts views Thread by Tamir Khason | last post: by
1 post views Thread by Keith Smith | last post: by
9 posts views Thread by Michael Turner | last post: by
reply views Thread by =?Utf-8?B?TWFydGluIw==?= | last post: by
reply views Thread by leo001 | last post: by

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.