473,387 Members | 1,394 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to detect when Tab Control loses its focus

Hello,

I have a WinForm application. The form has one Tab Control and one
ToolStrip. I would like to know what would be the best way to detect when
the user is "leaving" the Tab Control and "moving" into ToolStrip.

Thank you
EitanB
Aug 15 '07 #1
11 8034

You can handle the 'Leave' event of the TabControl to know when this object
loses focus and the 'Enter' event of the ToolStrip to know when the toolstrip
gets the focus.

Adrian.
--
[Please mark my answer if it was helpful to you]


"Eitan" wrote:
Hello,

I have a WinForm application. The form has one Tab Control and one
ToolStrip. I would like to know what would be the best way to detect when
the user is "leaving" the Tab Control and "moving" into ToolStrip.

Thank you
EitanB
Aug 15 '07 #2
Hello,

The leave on the Tab Control is not triggered when I press one of the
controls on the ToolStrip..... It only triggers when I switch tabs.

Thank you
Eitan

"Adrian Voicu" wrote:
>
You can handle the 'Leave' event of the TabControl to know when this object
loses focus and the 'Enter' event of the ToolStrip to know when the toolstrip
gets the focus.

Adrian.
--
[Please mark my answer if it was helpful to you]


"Eitan" wrote:
Hello,

I have a WinForm application. The form has one Tab Control and one
ToolStrip. I would like to know what would be the best way to detect when
the user is "leaving" the Tab Control and "moving" into ToolStrip.

Thank you
EitanB
Aug 15 '07 #3
Eitan wrote:
Hello,

I have a WinForm application. The form has one Tab Control and one
ToolStrip. I would like to know what would be the best way to detect when
the user is "leaving" the Tab Control and "moving" into ToolStrip.
I would expect the Enter and Leave events in the Control class to
provide that information. Is this not working for you?
Aug 15 '07 #4
Hello,

The Leave on the Tab Control is not triggered when I press one of the
controls on the ToolStrip..... It only triggers when I switch between tabs
on the Tab Control....

Thank you
Eitan
"Peter Duniho" wrote:
Eitan wrote:
Hello,

I have a WinForm application. The form has one Tab Control and one
ToolStrip. I would like to know what would be the best way to detect when
the user is "leaving" the Tab Control and "moving" into ToolStrip.

I would expect the Enter and Leave events in the Control class to
provide that information. Is this not working for you?
Aug 15 '07 #5
Eitan wrote:
Hello,

The Leave on the Tab Control is not triggered when I press one of the
controls on the ToolStrip..... It only triggers when I switch between tabs
on the Tab Control....
But do you not get an Enter event for the ToolStrip?

It seems to me that if you don't get a Leave event for the Tab Control,
the technically the Tab Control hasn't actually lost focus. So in some
respect, you are asking the wrong question. Perhaps you should look
more closely at what UI changes actually occur when what you think is
focus changing happens.

All that said, there's always the WndProc. You can override the WndProc
for the Tab Control and see what messages are sent when the UI changes
in the way you want to detect (for example, use Debug.WriteLine() to
trace the message values). Then you can either take advantage of that
information to find a managed way to handle the change, or just keep the
WndProc overridden and watch for those same messages.

Pete
Aug 15 '07 #6
The TabControl is loosing the focus you are right.

Using the WndProc might be a good idea. How would one trap the WndProc
messages?

Thank you,
Eitan

"Peter Duniho" wrote:
Eitan wrote:
Hello,

The Leave on the Tab Control is not triggered when I press one of the
controls on the ToolStrip..... It only triggers when I switch between tabs
on the Tab Control....

But do you not get an Enter event for the ToolStrip?

It seems to me that if you don't get a Leave event for the Tab Control,
the technically the Tab Control hasn't actually lost focus. So in some
respect, you are asking the wrong question. Perhaps you should look
more closely at what UI changes actually occur when what you think is
focus changing happens.

All that said, there's always the WndProc. You can override the WndProc
for the Tab Control and see what messages are sent when the UI changes
in the way you want to detect (for example, use Debug.WriteLine() to
trace the message values). Then you can either take advantage of that
information to find a managed way to handle the change, or just keep the
WndProc overridden and watch for those same messages.

Pete
Aug 15 '07 #7
Eitan wrote:
The TabControl is loosing the focus you are right.

Using the WndProc might be a good idea. How would one trap the WndProc
messages?
http://msdn2.microsoft.com/en-us/lib...l.wndproc.aspx
Aug 15 '07 #8
Thanks
Eitan

"Peter Duniho" wrote:
Eitan wrote:
The TabControl is loosing the focus you are right.

Using the WndProc might be a good idea. How would one trap the WndProc
messages?

http://msdn2.microsoft.com/en-us/lib...l.wndproc.aspx
Aug 15 '07 #9
I read the article with the example for a form. How ever, how would I
overide the WndProc for a control (TabPage) on the form?

In my case, the form is defined as:
public partial class WeldProgramSetup : Form

My TabControl is defined as:
private System.Windows.Forms.TabControl tabControl_WP_ChannelInfo;

and my TabPage is defined as:
private System.Windows.Forms.TabPage tabPage_WP_Flow;

Thank you,
Eitan

"Peter Duniho" wrote:
Eitan wrote:
The TabControl is loosing the focus you are right.

Using the WndProc might be a good idea. How would one trap the WndProc
messages?

http://msdn2.microsoft.com/en-us/lib...l.wndproc.aspx
Aug 15 '07 #10
Eitan wrote:
I read the article with the example for a form. How ever, how would I
overide the WndProc for a control (TabPage) on the form?
The same way you do it for a form: you create a new class that inherits
the class you want to override, and use that class in place of the
original one.

Pete
Aug 15 '07 #11
On Aug 15, 12:34 pm, Eitan <Ei...@discussions.microsoft.comwrote:
Hello,

I have a WinForm application. The form has one Tab Control and one
ToolStrip. I would like to know what would be the best way to detect when
the user is "leaving" the Tab Control and "moving" into ToolStrip.

Thank you
EitanB
I use the Validating Event handler.

http://msdn2.microsoft.com/en-us/lib...alidating.aspx

Aug 15 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: (Pete Cresswell) | last post by:
I've got a TreeView on the left of my screen. As the user navigates the tree, I load corresonding detail info into the rest of the screen. Works ok, but when the user clicks on a detail field,...
1
by: (Pete Cresswell) | last post by:
I'm using a subform as a navigation list. On the left side of the screen is a subform containing people's names. The right side of the screen is loaded with information about the...
5
by: Vinny Vin | last post by:
I would like to display a ToolTip (WinForms) when the Control associated recieves focus (when the control.enter event is triggered) as oppose to having the ToolTip displayed when the mouse hovers...
3
by: Gidi | last post by:
Hi, Is it possible to know when TextBox loses focus to which object it lost it? what i mean is when the LostFocus Event occur is it possible to know which object got the focus instead? thanks,
3
by: Greg | last post by:
The LostFocus event of datagrids is fired when the focus is added to a cell. How do you go about detecting it when the control as a whole has lost focus to another control? Slightly confused by...
1
by: jjwhite01 | last post by:
I am working on a web form that contains a Calendar control with an image button that makes the calendar appear and disappear. However, I would like to set the visible property of the Calendar...
2
by: bg_ie | last post by:
Hi, I have a treeview where the user selects a node before editing it. The problem is that when the user clicks on the text box to edit the node, the treeview loses its focus and the node is no...
3
by: Stanton | last post by:
How can I get an image to appear when a control has the focus in a form? I would assume expression builder might be useful, but whenever I try to put an expression into an event box, it tries to...
3
by: StinkyDuck | last post by:
Is there a way to detect when a control gains focus on a webform? Say I have two text boxes. After the user types in information on the first text box and hits the tab key or clicks on the second...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.