hi! I have an UltraTree with LabelEdit=true
1) Creating some nodes with short words, for example
root
-node1
-node2
2) Copy to Clipboard some long line, for example "01234567890qwertyuioplkjhgfdsa"
3) Two clicks on the node1 or press F2
4) In editor, paste the text >> while editor has the needed width, text is not completely visible, as it is scrolled on the left "behind the screen" (see pic1)
6) now press left button and scroll whole text, so it became visible
7) click Escape, and then activate editor and paste the text again - it was shown and scrolled normally
---
how to fix this scrolling issue for the first paste ?
thanks
rilian
If I remember correctly, that is a bug in the TextBox control. The text being pasted is wider than the TextBox, and the SelectionStart property is set to bring the caret to the end, so it scrolls the last character into view. It seems to use the last size when it does, however, resulting in the beginning of the text being clipped.
Thanks, Brian,
Could this be fixed by setting SelectionStart=0 and SelectionLength=0 on the LabelEdit control after CTRL+V KeyPressed on it ?
Another question, how to get to this TextBox control in runtime ?
Here is the fix:
private readonly UltraTree tree = new UltraTree();
tree.Override.LabelEdit = DefaultableBoolean.True;
tree.KeyUp += tree_KeyUp;
...
void tree_KeyUp(object sender, KeyEventArgs e) { //this fixes TextBox bug when the text is not scrolled into view after paste if (e.KeyCode == Keys.V && e.Modifiers == Keys.Control) { TextBox internalTextBox = tree.ActiveNode.Control.Controls[0] as TextBox; if (internalTextBox != null) { internalTextBox.SelectionStart = 0; internalTextBox.SelectionLength = 0; } } }
When a node is being edited, it will be in the UltraTree's Controls collection. You can use UltraTree.ActiveNode.IsEditing to determine whether the control is in edit mode, and you can get a notification when the control is added using the ControlAdded event.