Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
875
Simple input masks at the WinGrid cell level
posted

Hi,

We're using WinGrid as a base class for a control that can contain a different data type in each cell. So each column isn't tied to just one data type. I need to support simple input masks (like "(xxx) xxx-xxxx" for a phone number) at the individual cell level.

I've found a few examples that show setting MaskInput, MaskDataMode, MaskClipMode, and MaskDisplayMode at the column level. I couldn't find any examples of how to do something like this as the individual cell level. (I even tried adding an UltraMaskedEdit as the editor control but that blew up; apparently it's not supported as a cell editor.)

I'm setting an UltraTextEditor as the editor for cells that need a mask in the OnAfterCellActivate() override (which is where I set up all the cell-specific stuff before editing since each cell can be any data type). I also tried setting the column-level masking in there, but I don't see any result from doing that, it's like there's no mask at all. Here's a snippet of the code from the OnAfterCellActivate() override that deals with masked text cells:

else if (CurrentItem.DataType == DataTypes.MaskedText)
{
    _maskedTextEditor.MaxLength = CurrentItem.MaxLength;
    ActiveCell.Column.MaskInput = CurrentItem.InputMask;
    ActiveCell.Column.MaskDataMode = Infragistics.Win.UltraWinMaskedEdit.
MaskMode
.Raw;
    ActiveCell.Column.MaskClipMode= Infragistics.Win.UltraWinMaskedEdit.
MaskMode
.IncludeBoth;
    ActiveCell.Column.MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.
MaskMode
.IncludeBoth;
    _maskedTextEditor.ReadOnly = CurrentItem.ReadOnly;
}

The Mask* settings here don't seem to have any effect. I'm not sure if that's because I'm using an UltraTextEditor as the cell editor (_maskedTextEditor, set outside of this code snippet), or if I'm setting this at the wrong time in the eventing, or what.

I'm also concerned that I'm setting the masked stuff at the column level when I really need the masking at the individual cell level. Each column can contain any number of cells of different data types.

I looked at data filters, but I need the masked literals available both during input and also stored in the database. Seems like a data filter is used to translate the form between input and the data layer.

Do I have any options here? Thanks in advance,

Jim Honeycutt