473,748 Members | 2,594 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 7566
"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
14300
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
2495
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
4305
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
1154
Atran
by: Atran | last post by:
Is there anyway to Change My Form Model? Mac Model, Linux Model..............................
6
2236
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
6006
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
1676
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
1343
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
4393
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
8996
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
8832
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,...
1
9333
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,...
1
6799
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
6078
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
4608
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...
1
3319
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
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.