Hi,
I have a requirement to support data validation within my editor control. To support this I've created a -class -which derives from Infragistics.Win.EditorWithMask.
I attach this editor to the appropriate grid cell when the Grid row is initialized. I configure it to display the mask - DisplayFormattedTextWhenNotFocused = true
In the InitializeRow event, I set this custom editor into the cell.
Cell.Editor = mUnitNoEditorCell.Column.MaskInput = "AAA\.AA\.AA"
In the InitializeLayout of the grid, I set this column up to return all characters :
.UseEditorMaskSettings = True -(edit- ' my first mistake).MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeBoth.MaskDataMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeBoth
And yet, I only see the mask when I am editing the cell. When the cell is not actively edited, the mask characters are removed.
This is not what I want. I want to see the mask and the characters at all times and I want the value of the column to be this as well. ( It is this when I set the value, but the mask characters are stripped out)
Please tell me where I've gone wrong. Thanks.
Edited: Summary of where I went wrong, (BTW - very frustrating experience with the half-there half-not there help docs and all the many control choices available - Why Me Lord.)
perrb01 said:To support this I've created a control which derives from Infragistics.Win.EditorWithMask.
EditorWithMask is not a control. Did you mean to say you derived a class from EditorWithMask?
perrb01 said:Cell.Editor = mUnitNoEditorCell.Column.MaskInput = "AAA\.AA\.AA"
This is a little odd. You are assigning the editor to the cell, but you are setting a mask on the entire column. This probably has nothing to do with the issue at hand, but I just want to make sure you are aware that the Column property on the cell applies to the entire column, but just the one cell. If you want to apply your editor to the whole column, you would be better off using the InitializeLayout event and just setting it once for the whole column instead of on each cell in InitializeRow. If you only want this editor on certain cells, then you should set the Mask property on the editor itself and then you will need an Editor Control, not just a class, and that means that you won'y be able to do any special validation on the editor-level.
perrb01 said:.UseEditorMaskSettings = True.MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeBoth.MaskDataMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeBoth
UseEditorMaskSettings means that the column will use the mask settings of the editor and the properties on the grid will be ignored. So MaskDisplayMode and MaskDataMode here will have no effect. If you want these properties to work, don't set UseEditorMaskSettings.
You seem to be mixing up a lot of different properties on different objects here. You are setting properties on the editor, cell, and column in very odd and even contradictory ways. There's so much going on here that's hard for me to know where to start. Perhaps if you explained in more detail exactly what you are trying to achieve, I could tell you the simplest way to do it.
Yep, I bet you get tired of all the goofy code combinations you see coming in to this forum.
I guess if information on how to actually use these controls were easier to find and less confusing - I could do a better job without asking for help.
So, you say this: "UseEditorMaskSettings means that the column will use the mask settings of the editor and the properties on the grid will be ignored" COOL! But how do I set the mask of the editor? I only see how to set the mask of the Column. - Thus, I feel I need to tell the column how to behave. But it just ignores me.
First question you can answer - how do I set the mask of this control: EditorWithMask
The mask comes from the owner, not the editor.
So if you need a different mask in each cell of the same column, there are a number of ways you can do it. The easiest way it to use an EditorControl (UltraMaskedEdit) instead of just an editor (EditorWithMask). The control has properties for the masks, just like the grid column does. So if you set the column's UseEditorMaskSettings and assign the cell's EditorContorl to an UltraMaskedEdit control, it will pick up the mask settings of the control.
But, this may not work for you and whatever validation you are trying to achieve by deriving a class from the editor, since the control will provide an editor to the grid. Which is why I asked for more details about what, exactly you are trying to achieve.
Most likely, you will not be able to do your validation on the editor level, you will have to do it using events of the grid.
Thanks, Mark.
How do I add the UltraMaskedEdit as an Editor to my column. - Please if you would be so kind - provide Sample Code.
This would be my preferred method, I did attempt it more than once.
When I do it the way I think it should be done, I am informed it doesn't support the correct interface.
Mark, I must provide validation within this control, not within the grid. The control is Enterprise level and the grid is project level.
perrb01 said:I must provide validation within this control, not within the grid. The control is Enterprise level and the grid is project level.
I don't believe this is possible. Or at least, it cannot be combined with also using a different mask in each cell.
Perhaps what you can do is provide some Enterprise level methods that the project can call into to validate the values.