Hello.
I know that the MinValue and MaxValue can be set on a column level, but how do you set it on a cell level?
I've managed a workaround by setting those properties on the column in the "BeforeEnterEditMode" event, but I'm not sure that that's the best way (see code, below).
Is there a better way?
Thanks in advance,
Mike
ugIncludedItems.BeforeEnterEditMode
ugIncludedItems.ActiveCell.Column.MaxValue =
).Value)
ugIncludedItems.ActiveCell.Column.MinValue = 0
Sub
Hello,
If you are following this approach you are setting MinValue and MaxValue on the column level and not on the cell level.
So you probably have to remove the style of the column and set an editor with the appropriate settings on each cell in the IntializeRow event like :
Private Sub ultraGrid1_InitializeRow(sender As Object, e As InitializeRowEventArgs) Dim unE As New UltraNumericEditor() e.Row.Cells("DesiredColumn").EditorComponent = unE unE.SpinButtonDisplayStyle = Infragistics.Win.ButtonDisplayStyle.OnMouseEnter unE.MaxValue = e.Row.Cells("MaxValueColumn").ValueEnd Sub
Please let me know if you have any further questions.
I'm pretty sure this will not work.If I am wrong, then it would certainly only work once you set the UserEditorMaskProperties on the column to true. But I suspect the MinValue and MaxValue cannot be set on a single cell.
You could, of course, trap the BeforeCellUpdate event and validate the value against whatever you want.
Hi, Mike. Thanks for the response.
The columns in question use "IntegerNonNegativeWithSpin" as the style and I was hoping to prevent users from spinning past the min/max. I do, however, use the BeforeCellUpdate to do exactly what you suggested for validation (just in case).
Two questions:
Thanks again,
Hi Mike,
milop said:What are any ill effects of the code I posted in my first post and
I'm not sure there's anything terribly wrong with it. But you should be aware that you are setting the MinValue and MaxValue on the entire column and not just the one cell. I'm not sure if it ever happens, but it's not entirely unreasonable that another cell in another row might get validated for some reason and at that point, the MinValue and MaxValue of the column would be incorrect. Like I said, I'm not sure if that ever happens - I don't think any non-active row will be validated by the grid, but it's something to keep in mind.
I'm also not thrilled about using BeforeEnterEditMode for this. I'd probably use BeforeCellActivate or even BeforeRowActivate, just to be safe.
milop said:What do I need to do to enable the Enter key to trigger the update? Right now the user has to leave the row in order for this to occur.
Trap the grid's KeyDown or maybe KeyPress and then you can commit the changes to the current active row like this:
grid.PerformAction(ExitEditMode)
grid.ActiveRow.Update()
Nevermind, Mike. I had the "AcceptButton" property set on a button on the form. When I removed it the Enter key raised the event.
Now I have to figure out how to get around that.
Mike,
I wasn't too crazy about changing the Min/Max on the column. I'll have to rethink it.
On the second question, the Enter key isn't firing either event (KeyDown or KeyPress).
I have breakpoints set and they are not hit when I press Enter, though every other key raises the events.
What gives?
Thanks,