As a fresh continuation to this thread I have found a new problem.
There's this flexgrid that has a textbox to help editing the cells (to benefit from its selstart & sellength properties) and you can click on the cells with the mouse or type return / arrow keys to navigate. When you get to row 8 a checkbox shows up -and diappears when you leave that row. However, after adding a new control to the form (a command button) it turns out it gets the focus when you reach row 8 by typing arrow up or arrow down. Yet this does not happen if the code is run in step mode.
I'd like to ask you guys to try out the attached demo project and enlighten me for I'm at a loss.
PS: looks like I've sent 2 versions of the thread, my IE crashed the first time so I wasn't sure it had gotten through.
Last edited by krtxmrtz; Oct 5th, 2006 at 06:02 AM.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Ok the command button gets focus because the Tab index of the check box is 1 and the button is 2. Set the tabstop to false and it works.
Right but, the thing is, I need the possibility to navigate throughout the form's different controls with the keyboard -just like mostly any application out there.
What I don't understand is, I've run this in step mode to figure out where exactly the command button gets the focus, but to no avail as it doesn't happen in step mode.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Ok the command button gets focus because the Tab index of the check box is 1 and the button is 2. Set the tabstop to false and it works.
mmm... I'm afraid I misunderstood you.
I've now set (only) the checkbox tabstop property to false and now it works.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Yes the problem was that the check box took focus instead of the cell and then passed the focus to the button, but why it didn't do it debug is a mystery...
focus things often do not work right in step mode as the focus is lost to the code window, in between
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Yes the problem was that the check box took focus instead of the cell and then passed the focus to the button, but why it didn't do it debug is a mystery...
Still I don't understand the logic.
I have placed debug.prints in all subs to track down the order of events (in non-step execution mode) and the result is,
A. Arrow down (or arrow up) from one row to another, different from row 8:
I just can't figure out when and where Text1 loses focus (event #5) and why in the first case command1 returns the focus after having gained it...
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Oh I forgot to add debug.prints to these -I used an automatic utility and they were not visible as they have no code.
After placing statements in these event handlers I get the same for case A and the following for case B:
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Oh I forgot to add debug.prints to these -I used an automatic utility and they were not visible as they have no code.
After placing statements in these event handlers I get the same for case A and the following for case B:
Actually I got this after I'd placed a delaying loop in the Command1_GotFocus and in Command1_LostFocus subs. When I removed these loops I got exacltly the same as in post #7.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
I think I have finally solved the "focussing logic".
What I've done is:
1. Make TabStop = True for the grid and False for the textbox and checkbox.
2. At the end of the SetUpCheckBox procedure I have added the statement "grid.SetFocus".
Attached are the corrected zipped project files.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)