473,699 Members | 2,822 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detect change of focus on form?

kkk
I need to control something (visibility of toolbar buttons) when the cursor
moves between fields on a form (using VB .net). How do I detect that the
focus has moved?

Thanks,
Paul.
Nov 20 '05 #1
7 7561
"kkk" <kk*@kkk.com> schrieb
I need to control something (visibility of toolbar buttons) when the
cursor moves between fields on a form (using VB .net). How do I
detect that the focus has moved?

The control gets the Gotfocus/Lostfocus event.
--
Armin

Nov 20 '05 #2
Hi kkk,

Have a look at the lostfocus event that is in every control (form textbox
etc)

Cor
Nov 20 '05 #3
* "kkk" <kk*@kkk.com> scripsit:
I need to control something (visibility of toolbar buttons) when the cursor
moves between fields on a form (using VB .net). How do I detect that the
focus has moved?


Loop through all controls recursively and add a common handler to their
'LostFocus' and 'GotFocus' events. There you can easily detect if
another control gets focus.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
Hi kkk,

Herfried helped me to tell that I had a complete sample for that

I hope it helps

Cor

\\\
Dim last As String
Private Sub Form5_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
doset(Me)
End Sub
Private Sub doSet(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Contr ols
AddHandler ctr.LostFocus, AddressOf meLostFocus
AddHandler ctr.GotFocus, AddressOf meGotFocus
doSet(ctr)
Next
End Sub
Private Sub meLostFocus(ByV al sender As Object, _
ByVal e As System.EventArg s)
last = DirectCast(send er, Control).Name
End Sub
Private Sub meGotFocus(ByVa l sender As Object, _
ByVal e As System.EventArg s)
DirectCast(send er, Control).Text = last
End Sub
///
Nov 20 '05 #5
qqq
Thanks for all the suggestions, which I see will work. But is there no way
to do this without having to put a handler on each control? Is there no
FORM-level event that I can handle?

THanks, Paul.
Nov 20 '05 #6
Hi Paul,

With my solution you set them in one time to all.

Cor
Nov 20 '05 #7
You can hook mouse events + keyboard ones on form and analyze where is
mouse, which key is pressed and find out controls underneath mouse / cursor.
But I think it will be much more complex and unnecessary, especially
considering that controls could be added / removed dynamically.

HTH
Alex

"qqq" <qq*@qqq.com> wrote in message
news:uT******** ******@TK2MSFTN GP10.phx.gbl...
Thanks for all the suggestions, which I see will work. But is there no way
to do this without having to put a handler on each control? Is there no
FORM-level event that I can handle?

THanks, Paul.

Nov 20 '05 #8

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

Similar topics

2
14294
by: fish | last post by:
Hi, I have an HTML page with a FORM and some input fields. On the fields I wish to do validation as the punters change the field values. If they get it wrong, then I tell them and then wish to put the focus back to the offending field. ( It works if a use an 'onblur' event but not an 'onchange' )
6
2491
by: Brian | last post by:
I'm trying unsuccessfully to use a variable in a script that changes focus. Depending on which link a user follows (navigates via keyboard or clicks), I'd like to change the focus to an input name="q" in different forms on the page. <A onClick="changeFocus('basicsearch')" HREF="#basic">basic site search</A> <A onClick="changeFocus('advancedsearch')"
4
4302
by: Jon Slaughter | last post by:
I've created some custom controls and forms that allow the feature to temporarily transfer focus to a control that has been entered by the mouse. Everything seems to work fine but the problem I have is that sometimes I seem to loose the original "holder" of focus and when the user hits tab while using "temporary" focus(while the mouse is over a control) it will change focus to the next control but not update it. So I have several issues....
4
1153
Atran
by: Atran | last post by:
Is there anyway to Change My Form Model? Mac Model, Linux Model..............................
6
2233
by: Steve | last post by:
Hi All I have an on-screen keyboard within a POS program I have written in VB.net 2005, for touch screen computers I have it set to 'always on top' so the user can move the cursor to different text boxes and type using the on-screen keyboard The keyboard launches via the mouseclick event for any text box If another form is launched, with the onscreen keyboard still visible, the
2
6004
by: satishnandigam | last post by:
Hi all, I am new to c#. Can any one help to how to change the form name in c#. Thanks In Advance. N.Satish
2
1670
by: sreemati | last post by:
Hi One of the web form has 3 dates fields: Date of form entry, date of diagnosis and date of death. Date of form entry has future date validation done which I thought of extending to the other two date fields. Code being used already: function checkFutureDate(day, month, year, formName)
1
1340
by: Anwesha | last post by:
Hi, i have a problem while working with .net 2005. i have a situation where i have to change the form id which takes 'form1' by default. it donot allow me to change the id form the property window. is there any procedure to change the id of the form....plz help...
7
4392
by: Jesse Jones | last post by:
Any ideas on how to send info from one form into another domain or how to write a default value for a new user's password with a formula? Here's what I'm trying to do: design my database so that a new employee record has a password generated with a formula (obviously, not one that is published). On the employees table is a true false declaring if the user's password needs changed. The default value is true. So when I create a new record (add...
0
8704
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
9054
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...
0
8895
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
6545
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
5879
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
4390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3071
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2362
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.