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
110
UltraTreeNode Editor - Need masked editing with specific characters
posted

I'd like to have the ability to rename an UltraTreeNode (ie: the label), but only allow alphanumeric characters and underscores. Is there a way to do this, preferably with an upper limit of 28 characters.

I can trigger the edit just fine with BeginEdit(), but the EditorWithMask seems inflexible.  How do I catch when the editing is finish, is this by processing the AfterLabelEvent of the UltraTree? Do I need an EndEdit at all?

 

Is it possible to have a tooltip pop up if the user types an invalid character?

 

Thanks

  • 469350
    Verified Answer
    Offline posted

    Hi,

    If you want to try to validate the text after the user is done editing, you can use the ValidateLabelEdit event. AfterLabelEdit is too late, because the node will have already left edit mode. ValidateLabelEdit let's you keep it in edit mode.

    If you want to validate as the user types, then I think you will have to get a hold of the TextBox that is positioned over the node. Try hooking the ControlAdded/ControlRemoved events of the tree. In ControlAdded, you can see if the control is a TextBox and if so, hook some events like KeyDown or KeyPress. Then you can handle those events to validate each keystroke. Just be sure to unhook the same events in ControlRemoved.