How i can give focus to a cell in the grid (in case of new row or in case of editing the existing row).
thanks,
parv
You can't do this in BeforeCellUpdate. BeforeCellUpdate fires while the grid is in the middle of an update. Leaving the cell triggers the update. So you are trying to force focus on a another cell while you are already in the process of moving to another cell.
This code does not make a whole lot of sense. You get the the "Quantity" cell in the active row, and then you are checking the key of the column. Why? You already got a cell from a specific column. It will always be from the Quantity column, because that's what you are asking for. But this may or may not be the cell that is being edited. You probably mean to be looking at the ActiveCell.
It sounds like you just want to stop the cell from losing focus if the value the user has entered failed validation. If that's the case, then you should use the BeforeExitEditMode event.
Hi,
I tried activecell and activate but nothing worked for me. Check code given below.
Please let me know where i'm wrong.
Thanks,
Dim aa As Decimal
Dim ab As String
aCell = Me.UltraGrid1.ActiveRow.Cells("Quantity")
If aCell.Column.Key = "Quantity" Then
aa = e.NewValue 'e.Row.Cells("Quantity").Value
If aa > 100 Then
ab = aa
'Me.UltraGrid1.ActiveCell = e.Cell
'Me.UltraGrid1.Focus()
'Me.UltraGrid1.ActiveRow = e.Row
'Me.UltraGrid1.PerformAction(UltraGridAction.EnterEditMode, False, False)
aCell.Activate()
e.Cancel = True
End If
End Sub
Hi Parv,
You can call the Activate method on the cell or set the grid's ActiveCell to that cell. If you also want the cell to go into edit mode, then you could use the grid's PerformAction method for this.