For a client request, the grid must lost focus after commit the last cell of a row.I tried to do it in the event AfterExitEditMode, using Me.Control1.focus(), but the focus goes to Control1, and back to the grid.Is any way to do it?
The code you have here is very strange. It doesn't take into account why the cell exited edit mode. For example, suppose the user types into that cell and then clicks on some other control on the form. You are going to take focus away from whatever control they clicked on and force focus onto the button control. That's a really odd UI and it's sure to confuse your users.
If that's really what you want, then you need to let the grid and the form finish doing all the processing of the mouse or key event that is happening. One way to do that would be to use a BeginInvoke to call the Focus method instead of calling it directly. That will create a delay so that the code doesn't execute until the current operation is finished.
You are placing a method inside an event that hasn't finished yet. By placing a focus method you are causing the grid's leave event to fire. In theory the AfterExitEditMode event hasn't finished yet and is still open even after you put focus on the button. The grid is put back into focus depending on what type of action you caused the AfterExitEditMode to fire.
Hi
I understand I can use the grid.UpdateData for commit the cell if I lost the focus (i.e. doing click in an other control). But idea is to change the focus programatically.
Private Sub Grid1_AfterExitEditMode(sender As Object, e As System.EventArgs) Handles Grid1.AfterExitEditMode If Me.Grid1.ActiveCell.Column.Key = "LASTCOL" Then Me.Button1.Focus() End If End Sub
The focus goes to Me.Button1 but then backs to the next cell.
Hi,
It sounds like you just want the grid to commit any pending changes before you save the data to the back end. In that case, you can just call grid.UpdateData, or call the Update method on the active row.