Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
695
How to change input focus to specific cell?
posted

Need some guidance here.

 

Program requirements: -

1. When "Bool Col" checkbox is tick and user click at "String Col", set "Int Col" value to 999.

2. When "Bool Col" checkbox is untick and user click at "String Col", set "Int Col" value to 0 and need the input focus change from "String Col" to "Int Col" to enforce user enter value more than 0.

 

Problem facing now at 2nd requirement: -

1. The "Int Col" value can be set to 0 but input focus cannot be change from "String Col" to "Int Col"

2. Cannot enforce user enter value more than 0.

 

Attached is sample application to demo my problem.

Parents
No Data
Reply
  • 469350
    Offline posted

    Hi,

    I'm not sure I understand what you are trying to do here. I see that when you set the bool col to false, you want to set focus to the Int Col cell.

    But using BeforeExitEditMode for this seems like a bad idea. This event is going to fire when the user tries to leave the Bool Col cell, no matter how they do it. They will be unable to click anywhere else in the grid or on any other control in the application that takes focus. Maybe that is what you want, but it seems odd.

    Anyway, you cannot set focus to another cell and enter edit mode on that cell from the BeforeExitEditMode event, because there is a cell which is still currently in edit mode and in the process of existing it.

    You can probably get around this by using a BeginInvoke to set the grid's ActiveCell and EnterEditMode, instead of doing it from directly inside the event.

    Another option would be to use the BeforeRowUpdate event to do your validation and just make sure the user does not leave the row, since the validation you are doing here depends on more than one cell.

Children