473,387 Members | 1,541 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.

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 7531
"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(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
doset(Me)
End Sub
Private Sub doSet(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Controls
AddHandler ctr.LostFocus, AddressOf meLostFocus
AddHandler ctr.GotFocus, AddressOf meGotFocus
doSet(ctr)
Next
End Sub
Private Sub meLostFocus(ByVal sender As Object, _
ByVal e As System.EventArgs)
last = DirectCast(sender, Control).Name
End Sub
Private Sub meGotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs)
DirectCast(sender, 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**************@TK2MSFTNGP10.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
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...
6
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...
4
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...
4
Atran
by: Atran | last post by:
Is there anyway to Change My Form Model? Mac Model, Linux Model..............................
6
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...
2
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
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...
1
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...
7
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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...

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.