I use a simple grid with UltraGridRowEditTemplate enabled.
If the validation fails how may I set the focus in a specific ultragridcellproxy?
How are you validating? You should be able to use the underlying grid's BeforeExitEditMode event and cancel it if your validation fails. Otherwise you should just be able to call Focus on a specific proxy.
-Matt
I use a class that has all the functionality of the control.
So the part that does the validation is as below:
Private Sub btnSaveAddress_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveAddress.Click 'Close the template and save any pending changes. Dim gRow As Infragistics.Win.UltraWinGrid.UltraGridRow = mGrid.ActiveRow If gRow Is Nothing Then Return Dim strError As String = "" If validateAddressRow(gRow, strError) = False Then ShowMessage(strError, "MB_ICONSTOP", False)
' I tried the following code, but fails
mUGridRowEditTemplate.Controls.Item("Address").Focus() Return End If
'now update row
.....
End Sub
I'm not sure what your ShowMessage method does, but if I just showed a MessageBox and then set focus to a proxy, it worked correctly for me. My guess is that either your ShowMessage is causing the focus to shift, or more likely something in your row updating logic is causing the ActiveCell of the grid to change, which would also cause the currently focused proxy to change.
Is this the right code:
mUGridRowEditTemplate.Controls.Item("Address").Focus()
where as:
mUGridRowEditTemplate is the member for the UltraGridRowEditTemplate and "Address" is the ColumnKey
Thanks for the quick responses
I used the exact same code and it worked for me. That code is not specific to the proxy, since you are just calling Focus on a generic control. You'll have to make sure that "Address" is the *name* of the actual proxy and not just the name of the column, though I'd think you'd get an exception if you didn't have a control named "Address".
Yes, it works, the "Addres" is the ColumnKey and I was getting an exception, as you mention, however when I changed to the name of the actual proxy it works perfectly.
Thanks a lot for your quick responses.