Thanks
Jaydel
private void mBOM50206UG_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) { //Create the Settings Object: DefaultEditorOwnerSettings theSettings = new DefaultEditorOwnerSettings();
//as well as the Editor Owner: DefaultEditorOwner theOwner = new DefaultEditorOwner(theSettings);
EmbeddableEditorBase theEditor = null;
object theValue = e.Row.Cells["QTYToTransfer"].Value;
//Create an appropriate editor based on the //Value's Data Type: if (theValue is decimal) { theSettings.DataType = typeof(decimal); //theSettings.Format = "n2"; theSettings.MaskInput = "nnn,nnn,nnn,nnn.nnnnn"; theEditor = new EditorWithMask(theOwner); }
//Assign it to the Cell.Editor e.Row.Cells["QTYToTransfer"].Editor = theEditor;
Hi,
Your code here can be made much simpler. You don't need a DefaultEditorOwner. The EditorWithMask already has a MaskInput property you can set directly.
So all you have to do is create a new EditorWithMask and set the MaskInput on it, then assign it to the cell.
The only other thing you have to do is tell the grid column to use the mask settings of the editor before it looks at the properties of the column itself. You do that by setting UseEditorMaskSettings on the column to true.
Sorry to need more information but I tried looking at doing this but I can't figure out how.
How do you set the MaskInput on an EditorWithMask? Unless I need to read into your post a little and I also have to create an editor, set the mask on it and then set the editor of the EditorWithMask to be the newly created editor.
I can't just say EditorWithMask.MaskInput which is what I think you are mentioning...
Mike Saltzman"]The EditorWithMask already has a MaskInput property you can set directly.
Hi Pete,
I apologize for the confusion. You are correct, there is no MaskInput property on the editor. For some reason, I was thinking about the MaskedEditor control, not the editor.
The code you have here is all fine. The only thing you need to add is to set the UseEditorMaskSettings property on the column to true.
One thing I would recommend, though, is that you create some sort of caching mechanism so that you re-use the same editor and the same owner for multiple cells. Any cells that will have the same mask can use the same editor and owner. Creating a new set of objects for each cell is using a lot of memory. Especially since the InitializeRow event can fire more than once for the same row.
ok, never mind, found my problem. There was some code after cleaning up all the format I was doing.
Hi, so I have a test application where I did the code above and it works fine (even without setting the MaskInput) I only set the format and it works fine.
But when I applied it to my actual application it doesn't work. I can't make the format to be applied to the column at all. I've debug both I don't see any difference on the column, data or editor settings... I've also changed the backcolor of the each cell on this column to make sure I wasn't setting the format to a different column...
private void UltraGridMeasuredResults_InitializeRow(object sender, InitializeRowEventArgs e) { try { DefaultEditorOwnerSettings settings = new DefaultEditorOwnerSettings(); settings.DataType = typeof(decimal); settings.Format = !string.IsNullOrWhiteSpace(e.Row.Cells[Structure.Parameter.DisplayFormat].Value?.ToString()) ? e.Row.Cells[Structure.Parameter.DisplayFormat].Value.ToString() : "#,###.00"; EditorWithText editor = new EditorWithText(new DefaultEditorOwner(settings)); e.Row.Cells[Structure.SampleAnalysis.Value].Editor = editor; e.Row.Cells[Structure.SampleAnalysis.Value].Appearance.BackColor = Color.Pink; } catch (Exception ex) { Messaging.LogAndShowErrorMessage(ex); } }
Any idea would be appreciated