Hi there,
I have a list of UltraCheckEditor controls set to EditCheckStyle.Custom , and am setting the text of these controls in code. I'm using Environment.NewLine to build the text, but nothing shows up after the first line.
Is what I'm trying to do possible, and if it is how do I go about making this work?
Hi,
UltraCheckEditor doesn't have any built-in support for multi-line text. But I was about to find a pretty simple workaround for you using a CreationFilter. All you have to do is tell the TextUIElement in the UltraCheckeditor to support multiline. So here's a little sample CreationFilter. You could create one instance of this class and attach it to any number of UltraCheckEditor controls and it watches for the creation of the TextUIElement and sets Multiline to true.
private MultiLineCheckEditorCreationFilter multiLineCheckEditorCreationFilter = new MultiLineCheckEditorCreationFilter(); private void Form1_Load(object sender, EventArgs e) { this.ultraCheckEditor1.CreationFilter = multiLineCheckEditorCreationFilter; this.ultraCheckEditor1.Text = "Line 1" + Environment.NewLine + "Line 2"; } public class MultiLineCheckEditorCreationFilter : IUIElementCreationFilter { #region IUIElementCreationFilter Members void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { TextUIElement textUIElement = parent as TextUIElement; if (textUIElement != null) { textUIElement.MultiLine = true; } } bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { // Do nothing. return false; } #endregion }
Mike Saltzman"] TextUIElement textUIElement = parent as TextUIElement; if (textUIElement != null) { textUIElement.MultiLine = true; }
Hi Mike,
Thanks for your answer, but I'm afraid it doesn't work - TextUIElement doesn't seem to be part of the hierarchy for the UltraCheckEditor. Stepping through, the closest it seems to get is ImageAndTextUIElement.ImageAndTextDependentTextUIElement. Unfortunately, setting multiline to true on that element throws a NotSupportedException
Never mind, I found it - I used ImageAndTextButtonUIElement setting multiline to true worked on that element. Thanks for steering me in the right direction.