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!

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    It would probably be easy to position an UltraTextEditor control over the header, rather than trying to do this using UIElements. The EditorWithTextUIElement is going to be relying on certain owner settings and methods that you don't have access to here. You're just passing in a DefaultEditorOwner here, but that's not going to be enough. You would have to derive a class of your own from EmbeddableEditorOwnerBase and override a bunch of methods and properties.

    What I would do is just use the CreationFilter to position an UltraTextEditor control over the HeaderUIElement.

Children