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
1360
Adding a texteditor to the header
posted

Hi,

I am trying to add an editable text editor into the header, so that the user can "set" the caption of the header at runtime. However, I am running into two problems:

1. The initial caption of the header isn't set in the text editor.

2. The text editor doesn't enter in edit mode, so I can't enter text.

We are using v7.3

This is my creation filter:

---------------------------------------------

internal class DesignCreationFilter : IUIElementCreationFilter
    {
        public DesignCreationFilter()
        {
        }

        public bool BeforeCreateChildElements(UIElement parent)
        {
            return false;
        }

        public void AfterCreateChildElements(UIElement parent)
        {
            try
            {
                if (parent is HeaderUIElement)
                {
                    parent.ChildElements.Clear();

                    var column = (UltraGridColumn)parent.GetContext(typeof(UltraGridColumn));

                    var editorText = new EditorWithText();
                    var editorOwner = new DefaultEditorOwner();
                    var editor = new EditorWithTextUIElement(parent, editorOwner, editorText, column.Header, true, true, true, false);
                    Rectangle rect = parent.ClipRect;
                    rect.Inflate(-2, -2);
                    editor.Rect = rect;

                    editorText.TextBox.Text = column.Header.Caption;
                    editorText.TextBox.ForeColor = Color.Black;
                    editorText.TextBox.Enabled = true;
                    editorText.TextBox.ReadOnly = false;

                    parent.ChildElements.Add(editor);
                }
            }
            catch (Exception ex)
            {
            }
          
        }
    }

 

 

Any ideas what could cause this behaviour?

 

Many thanks!