473,799 Members | 3,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8133

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 WeldProgramSetu p : Form

My TabControl is defined as:
private System.Windows. Forms.TabContro l tabControl_WP_C hannelInfo;

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

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

Similar topics

5
3319
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, the TreeView's selection rectangle goes away and the user is left wondering what happened. Seems like there ought TB a way to preserve that rectangle. The optimal would be to have it go grey when the control loses focus and return to blue whe...
1
1627
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 currently-selected person. As the user walks the list, the right side of the screen gets reloaded with info about each new name. When the user decides to change something, they click an "Edit" button that puts
5
9461
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 over the control,How can this be accomplished(Im developing in C#)?
3
2270
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
6141
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 this! Greg.
1
1899
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 control to false when the control loses focus so that when the user moves to the next field in the form the calendar disappears. Is there anyway to do this in ASP.NET or ASP.NET w/ Javascript?
2
13438
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 longer highlighted. To fix this I do something like - void treeView_AfterSelect(object sender, EventArgs e) { selectedNode.BackColor = Color.White;
3
1779
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 find the expression as a macro title and fails. (Also, I see Me comes up a lot in expressions, and wonder if that's why mine don't work... what does it mean??)
3
2026
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 text box, I want to automatically fill in the second text box with the information from the first text box. I just can't seem to find an event handler for when the control gains/loses focus. -StinkyDuck
0
9688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10260
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10243
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10030
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.