Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LostFocus on a Grid - Ain't There

Status
Not open for further replies.

fmoore0001

Programmer
Dec 3, 2002
192
US
Guys, I have a new problem. I did not know this, but their is no 'LOSTFOCUS' method for a grid. How can I tell when the focus on my grid has moved, or the grid1 can set itself as the current object when it is selected.

Again, I am trying to detect the current object. In other fields I did this in LOSTFOCUS, but I can't figure out a similar area in my grid.

Frank
 
I think you need to give a bit more detail about what you're doing. I know you said something about the user entering a value that determines which object is selected, but how does LostFocus come into the picture?


-BP (Barbara Peisch)
 
If I understand, I think you are looking for the AfterRowColChange Event
take a look at that

good luck
 
I have a form that I use universally for data find routines, and I want to improve how it operates.

I found that can assign the name of the current ActiveControl in the LOSTFOCUS event. I need to know the value of the last ActiveControl for a KEYPRESS routine. LOSTFOCUS appears to be the best for this name assignment to a THISFORM.var because the current ActiveControl is still known in the LOSTFOCUS event. By the VALID event it does not know the ActiveControl any more. I've tested it.

Now, I need to do the same when I am losing focus on an ActiveControl that is a grid. However, grids do not have a LOSTFOCUS event, so I was trying to see it there is an EVENT in a grid that would work the same for a grid as LOSTFOCUS in other controls. Edgardg says AfterRowColChange should do the trick. Any other suggestions would be checked out and I will report back.

Frank
 
If you drill down the grid to the control in each column, there is a loss focus method... e.g. grid1.header1.text1.lostfocus. You can focus the code in each columns' lostfocus method to pertain to the data stored in that column. Maybe that will help?

brian
 
Or maybe you're looking for Thisform.ActiveControl.Name as a global solution to know where the form's focus is?

Brian
 
The global solution for me is when I move from a control I save the control name to my THISFORM.lastcontrol variable (property?) so no matter what control or procedure I trigger I know what name of the LAST control I was on.

Frank
 
>> because the current ActiveControl is still known in the LOSTFOCUS event. By the VALID event it does not know the ActiveControl any more. I've tested it.

1/ Frank, how is this possible? I think Valid always run BEFORE Lostfocus, or not?

2/ Then: If you want save the information inside a method of some control, then you are not dependend on the .ActiveControl property. You can simply save THIS (or THIS.Name) in such method. THIS is always known, f.e. in Grid.Valid. (THISFORM.oLastControl=THIS)

3/ Grid (as all containers) hasn't LostFocus, but has Valid which is similar to LostFocus.

4/ When you write such information f.e. into some form property (or global application object property), you can write longer history as 1 object only - f.e. you can remember last 2 accessed objects in 2-elemenets array property. If so, then you can update this history earlier, f.e. in (succesfull) When method of some control: Move 1-st element to 2-nd and save THIS to the 1-st element. If you want then detect the previous control, take a look at the 1-st element and compare it with THISFORM.ActiveControl. If they are different, then 1-st element is previous control. If they are same, then 2-nd element is previous control.
 
I'm on the road, so I may not respond as quickly as I usually do.

Frank, are you saving the current control so that you can setfocus back to it after the find function is complete? If so, I think you really need to save the full object hierarchy ( sys(1272) ). I think what you need to use in the grid is the BeforeRowColChange, not necessarily the AfterRowColChange, but I haven't played with that enough to make sure.


-BP (Barbara Peisch)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top