1 Attachment(s)
[RESOLVED] Flexgrid with controls: new problem
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.
Re: Flexgrid with controls: new problem
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.
Re: Flexgrid with controls: new problem
Quote:
Originally Posted by Green Africa
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.
Re: Flexgrid with controls: new problem
Quote:
Originally Posted by Green Africa
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.
Re: Flexgrid with controls: new problem
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...
Re: Flexgrid with controls: new problem
focus things often do not work right in step mode as the focus is lost to the code window, in between
Re: Flexgrid with controls: new problem
Quote:
Originally Posted by Green Africa
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:
1 Text1_KeyDown
2 grid_LeaveCell
3 grid_EnterCell
4 SetUpTextBox
5 Text1_LostFocus
6 Command1_GotFocus
7 Command1_LostFocus
8 Text1_GotFocus
B. Same thing but now the destination row is 8:
1 Text1_KeyDown
2 grid_LeaveCell
3 grid_EnterCell
4 SetUpCheckBox
5 Text1_LostFocus
6 Command1_GotFocus
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... :confused:
Re: Flexgrid with controls: new problem
what about the checkbox.gotfocus?
Re: Flexgrid with controls: new problem
Quote:
Originally Posted by Green Africa
what about the checkbox.gotfocus?
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:
1 Text1_KeyDown
2 grid_LeaveCell
3 grid_EnterCell
4 SetUpCheckBox
5 chk1_Click
6 Text1_LostFocus
7 Command1_GotFocus
8 Command1_LostFocus
9 grid_GotFocus
10 SetUpCheckBox
Re: Flexgrid with controls: new problem
Quote:
Originally Posted by Myself
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:
1 Text1_KeyDown
2 grid_LeaveCell
3 grid_EnterCell
4 SetUpCheckBox
5 chk1_Click
6 Text1_LostFocus
7 Command1_GotFocus
8 Command1_LostFocus
9 grid_GotFocus
10 SetUpCheckBox
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.
Re: Flexgrid with controls: new problem
Matter of fact I had an inaproppriate tabindex order. Now I have:
grid (true/0)
command1 (true/1)
text1 (true/2)
chk1 (false/3)
and get:
Case A
Text1_KeyDown
grid_LeaveCell
grid_EnterCell
SetUpTextBox
Text1_LostFocus
grid_GotFocus
SetUpTextBox
Text1_GotFocus
Case B
Text1_KeyDown
grid_LeaveCell
grid_EnterCell
SetUpCheckBox
chk1_Click
Text1_LostFocus
grid_GotFocus
SetUpCheckBox
1 Attachment(s)
Re: Flexgrid with controls: new problem
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.