Results 1 to 12 of 12

Thread: [RESOLVED] Flexgrid with controls: new problem

  1. #1

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Resolved [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.
    Attached Files Attached Files
    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)

  2. #2
    Member
    Join Date
    Sep 2006
    Posts
    40

    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.

  3. #3

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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.
    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)

  4. #4

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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.
    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)

  5. #5
    Member
    Join Date
    Sep 2006
    Posts
    40

    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...

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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
    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

  7. #7

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Angry 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...
    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)

  8. #8
    Member
    Join Date
    Sep 2006
    Posts
    40

    Re: Flexgrid with controls: new problem

    what about the checkbox.gotfocus?

  9. #9

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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
    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)

  10. #10

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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.
    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)

  11. #11

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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
    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)

  12. #12

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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.
    Attached Files Attached 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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width