Hi,
I am working to support Thai language. The main problem is the UltraDateTimeEditor does not support to show Thai year correctly (Thai year = normal year + 543). I have made a custom control by combining UltraMaskedEdit, UltraMonthViewMulti. And it works fine.
The problem now is the editor for the cell in the grid. I cannot figure out how to make a custom editor similar like the one above. I tried to create a class to inherit from UltraMaskedEdit, then add the ButtonsRight and UltraMonthViewMulti but I always get this exception
Message: The Owner specified a type to EditorWithMask that is not supported by the editor.
StackTrace Information********************************************* at Infragistics.Win.UltraWinMaskedEdit.MaskInfo..ctor(EditorWithMask maskEditor, EmbeddableEditorOwnerBase owner, Object ownerContext) at Infragistics.Win.EditorWithMaskEmbeddableUIElement.SyncOwnerInfo(Boolean forceRegetValueFromOwner) at Infragistics.Win.EditorWithMaskEmbeddableUIElement.SyncOwnerInfo() at Infragistics.Win.EditorWithMaskEmbeddableUIElement.OnBeforeDraw() at Infragistics.Win.EditorWithMaskEmbeddableUIElement.PositionChildElements() at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UltraWinGrid.RowColRegionIntersectionUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UltraWinGrid.DataAreaUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UltraWinGrid.UltraGridUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UIElement.VerifyChildElements(Boolean recursive) at Infragistics.Win.ControlUIElementBase.VerifyIfElementsChanged(Boolean verify, Boolean syncMouseEntered) at Infragistics.Win.ControlUIElementBase.VerifyIfElementsChanged(Boolean verify) at Infragistics.Win.ControlUIElementBase.ProcessMouseMoveHelper(Object sender, MouseEventArgs e) at Infragistics.Win.ControlUIElementBase.ProcessMouseMove(Object sender, MouseEventArgs e) at Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e) at Infragistics.Win.UltraControlBase.OnMouseMove(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseMove(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Can someone show me the correct way to do a custom editor for a grid?
Hello Kim,
If I understand you correctly you have created an User Control and need to embed it in UltraGrid’s cell. Did you try to achieve this via UltraControlContainerEditor? This component provides you with the ability to embed non-editor controls in any Infragistics control that supports embeddable editors, like UltraGrid.
For additional information about how to embed any control into UltraGrid cell you may check the following article in our online documentation – “Embed Any Control within WinGrid Cell using UltraControlContainerEditor Component”.
Please let me know if this solves your issue or if you have any additional questions on this matter.
Hi Milko,
I have successfully create a custom editor using UltraControlContainerEditor. But I got an issue, when I tab out of the grid, the value of the cell is blank. I don't set the RenderingControl property, I just set EditingControl. EditingControlPropertyName will point to a property which is a DateTime? type.
Not sure if I miss anything?
Actually, I found out the problem. I did not implement the {PropertyName}Changed event. Add that to my custom editor and it works.
Another issue is my custom editor size does not fit the size of the column. Can you show me the way to make custom editor always fit to the cell?
Hi Kim,
I am glad to hear that you have resolved your issue.
Regarding your second issue, about fitting the custom editor in the column, you need to set the column width and the row height. In InitializeLayout event you can add code like this:
e.Layout.Override.DefaultRowHeight = yourCustomControl.Height;e.Layout.Bands[0].Columns["Your Thai Date Column"].Width = yourCustomControl.Width;
Please let me know if you have any additional questions on this matter.
What I mean is when I resize the column of the grid. The width of my custom editor should be adjusted based on the new width of column.
Thank you for your feedback.
In this case you should do the opposite. Get the column width and set the same width to your user control. You can achieve this by handling AfterColPosChanged event of the grid. Check if ColumnPosChandedType is Sized. If so check each changed column and if your Tai date column was changed set the width of your user control to match the new column width. You may use code like this:
private void UltraGrid_AfterColPosChanged(object sender, AfterColPosChangedEventArgs e){ if(e.ColumnPosChangedType == PosChangedType.Sized) { foreach(var header in e.ColumnHeaders) { if(header.Caption == "Your Tai Date Column Caption") { yourCustomControl.Width = header.Column.Width; } } }}