i want to give focus to a specific column if data entered in a row is not valid.
for example, there are 3 field, code, location, quantity, code has to be entered, location has to be entered, quantity has to be more than zero.
before i exit the row, if location or quantity is not entered, i want to show the message to user 'please enter location' and after use press ok the focus go to location coloumn of the row
also in case quantity is less than zero, show message to the user 'invalid quantity' and on press of ok, focus go to quantity column of the row.
is there a way to achieve this?
thanks in advance.
Parv
Hi Parv,
It think you can do this using the BeforeRowUpdate event. You can check the values in the row and if any of them are invalid, you can set e.Cancel to true and Activate the cell you want.
You might also want to take a look at the BeforeRowUpdateCancelAction property. I'm not sure you need it, but this property determines what happens when you cancel BeforeRowUpdate.
Hi Mike,
Thanks for the reply. I was away for a while and didn't get chance to test it. I looked into it but not worked for me.
1st, when i make e.cancel to true then it clear all the data entered in the row. I don't want the data to be get cleared. I'm giving the code for your review. In this case i want to give focus to quantity field if quantity is more than 100 and rest of the cell value suppose to remain there.
Can you give some suggestions to handle it?
Thanks in advance,
Dim aa As Decimal
Dim ab As String
aCell = e.Row.Cells("Quantity") 'Me.UltraGrid1.ActiveRow.Cells("Quantity")
aa = aCell.Value 'e.Row.Cells("Quantity").Value
If aa > 100 Then
ab = aa
'Me.UltraGrid1.Focus()
Me.UltraGrid1.ActiveCell = aCell
e.Cancel = True
End If
End Sub
Okay, well... if you read the second sentence of my post and look at the BeforeRowUpdateCancelAction property, you can set it so it doesn't clear changs.
hi Mike,
i'm unable to find out this property. I looked in the help etc but not sure how i can set it?
Thanks,
This is a property on the grid control itself or maybe on the DisplayLayout. If it's not there, then you may be using a old version of the controls before it was added. What version are you using?
I'm using 8.1.20081.1000
Not found the property anywhere.
Can you advise?
I don't know why you can't find it, then. I looked and it's a property on the UltraWinGrid control. It's definitely in v8.1.
this.ultraGrid1.RowUpdateCancelAction = RowUpdateCancelAction.RetainDataAndActivation;