How can I catch tab change on a TabControl?

  • Thread starter Thread starter David Rose
  • Start date Start date
D

David Rose

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
 
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 said:
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]
- (e-mail address removed)

David Rose said:
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
 
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 said:
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


in message news:[email protected]...
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]
- (e-mail address removed)

David Rose said:
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
 
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 said:
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 said:
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


in message news:[email protected]...
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]
- (e-mail address removed)

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
 
Back
Top