473,473 Members | 1,469 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

getting the last control in focus

Hello there
Is there a way to get the last control that was in focus before the current
control?
please note that I don't want the next or previous control in the tab order,
I need the last one used by the user.
Thanks in advance.
Regards
Sameh
Nov 20 '05 #1
4 5302
Hi Sameh,

I do not know if that is standard on the other hand in my opinion is it not
to difficult to make
When you build a general lost focus event than you can set the last control
name in that.
Than you know always what was the last.

Just a thought I do not remember it if I ever did tried it.

Cor
Hello there
Is there a way to get the last control that was in focus before the current control?
please note that I don't want the next or previous control in the tab order, I need the last one used by the user.
Thanks in advance.
Regards
Sameh

Nov 20 '05 #2
Hello Cor
may I ask what do you mean by a general focus event, how do you do that?
it will be a hell of a job to create a lost focus event for every control on
each form!
Thanks for your time
Regards
Sameh
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uM**************@TK2MSFTNGP09.phx.gbl...
Hi Sameh,

I do not know if that is standard on the other hand in my opinion is it not to difficult to make
When you build a general lost focus event than you can set the last control name in that.
Than you know always what was the last.

Just a thought I do not remember it if I ever did tried it.

Cor
Hello there
Is there a way to get the last control that was in focus before the

current
control?
please note that I don't want the next or previous control in the tab

order,
I need the last one used by the user.
Thanks in advance.
Regards
Sameh


Nov 20 '05 #3
Hi Sameh,

Fool I am, it is my standard sample for setting dynamicly handlers.
Set some textboxes than you see everytime the name in the last.

I hope this 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 #4
* "Sameh Ahmed" <es******@hotmail.com> scripsit:
Is there a way to get the last control that was in focus before the current
control?
please note that I don't want the next or previous control in the tab order,
I need the last one used by the user.


Recursively loop through the controls and add a handler to their
'LostFocus' event. This handler will receive the event for all
controls. Inside the handler, you can cast 'sender' to 'Control' and
assign it to a private member.

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

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

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
10
by: fotzor | last post by:
Hi, I'm a C++-Programmer and want to subclass the Edit used to write a SQL-Query in Access. The edit is of the special Access class OKttbx. Everything works, I injected a DLL into the...
2
by: Gerry Abbott | last post by:
Hi all. Im using abbreviated field names on a form to optimise space, but would like to display for example, the status bar text of the control, onto the form header, when the control has the...
2
by: Peder Y | last post by:
Anyone knows if there is some kind of property or function that will return the last selected/deselected item/index in a multiselect ListBox? SelectedIndex will point to first index in the...
1
by: clickon | last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains a text box, TextBox1 and TextBox2 respectively. If i put the following code in the respective activate event handlers for...
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...
7
by: Neil | last post by:
I have some code in my form's On Current event which changes focus to a particular control. I want the control to remain where it was when the user moved to the new record. But using...
2
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi all! I have one combobox, two grids and nine textbox. All textbox are tab index one following another. When I press tab I go to the next textbox. How can I known if I click on another...
7
by: Andrus | last post by:
I have UserControls in MDI child forms containing TextBoxes and other controls. When user re-activates form, I need that Control which was last activated is activated again. Currently *first*...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
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.