Hi
i'm using an UltraTree with editing mode enabled but when editing, if the user right clicks and selects 'Add new child’ the Tree throws an exception when I try to end edit mode and add a new row. I also tried just exiting the context menu and not allowing an add new to execute but even doing this the tree disables editing of the cells and in some cases rows cannot be selected again.
Me.TreeControl.Override.LabelEdit = Infragistics.Win.DefaultableBoolean.True 'enables F2 editing
Me.TreeControl.Override.Multiline = Infragistics.Win.DefaultableBoolean.False
Me.TreeControl.Override.LabelEditAppearance.BackColor = Drawing.Color.LightYellow
Me.TreeControl.Override.UseEditor = Infragistics.Win.DefaultableBoolean.True
Me.TreeControl.Override.Editor = New Infragistics.Win.EditorWithText()
Protected Overridable Sub onTreeAddChildClicked(ByVal Sender As Object, ByVal e As EventArgs)
Try
' This kills off editing at the row level. The cell does not highlight when selected and often the blue "selected" background is left in place (even when not selected)
If _TreeControl.ActiveNode.IsEditing Then
Exit Sub
End If
' Kills the controls and disables it perminately. The control has Red Cross displayed, exception thrown.
Me.TreeControl.PerformAction(UltraTreeAction.ExitEditMode, False, False)
' CODE TO ADD NEW CHILD ROW
Catch ex As Exception
End Try
End Sub
Questions:
Apart from disabling the context menu is there any way to get the control out of edit mode and/or reset it?
I get 2 slightly different exceptions depending on what action is taken in the context menu event. If just exitedit mode, the first exception is thrown, if exitedit mode and attempt to insert new row I get 2nd exception (note the key used on the newly inserted row is not a duplicate and is not the key mentioned in the exception)
I would appreciate any help with this.
Object reference not set to an instance of an object.
Source Assembly: Infragistics4.Win.v11.2
Method: OnTextBoxTextChanged
Stack Trace:
at Infragistics.Win.EditorWithText.OnTextBoxTextChanged(Boolean fireValueChanged)
at Infragistics.Win.EditorWithText.Infragistics.Win.IEmbeddableTextBoxListener.OnTextChanged()
at Infragistics.Win.EmbeddableTextBox.OnTextChanged(EventArgs e)
at System.Windows.Forms.TextBoxBase.WmReflectCommand(Message& m)
at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
at System.Windows.Forms.TextBox.WndProc(Message& m)
at Infragistics.Win.EmbeddableTextBoxWithUIPermissions.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Item has already been added. Key in dictionary: 'Watch List' Key being added: 'Watch List'
Source Assembly: mscorlib
Method: Insert
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at System.Collections.Hashtable.Add(Object key, Object value)
at Infragistics.Win.UltraWinTree.NodeClientAreaUIElement.CacheNodeElements(Hashtable table, UIElementsCollection oldElements, Int32 startIndex)
at Infragistics.Win.UltraWinTree.NodeClientAreaUIElement.PositionChildElements()
at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
at Infragistics.Win.UIElement.VerifyChildElements(Boolean recursive)
at Infragistics.Win.UIElement.VerifyChildElements()
at Infragistics.Win.UltraWinTree.UltraTreeUIElement.PositionChildElements()
at Infragistics.Win.ControlUIElementBase.VerifyIfElementsChanged(Boolean verify, Boolean syncMouseEntered)
at Infragistics.Win.ControlUIElementBase.VerifyIfElementsChanged(Boolean verify)
at Infragistics.Win.ControlUIElementBase.ProcessMouseMoveHelper(Object sender, MouseEventArgs e)
at Infragistics.Win.ControlUIElementBase.ProcessMouseMove(Object sender, MouseEventArgs e)
at Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e)
at Infragistics.Win.UltraControlBase.OnMouseMove(MouseEventArgs e)
at Infragistics.Win.UltraWinTree.UltraTree.OnMouseMove(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseMove(Message& m)
Hello,
I will be happy to assist you further on that matter if you could attach a sample project to your next post reproducing the mentioned behavior since I was not able to get these exceptions.
Please do not hesitate to contact us if you need any additional assistance.
I am checking about the progress of this issue. Please let me know If you need any further assistance on this.
I have a similar issue.
I have an UltraTree in freeform style.
Each Node in has two columns : Label and Value
I want to disable some item on then context menu
I want to keep Cut, Copy, Paste, Delete, Select All and hide the others e.g. Right to left Reading Order, Open IME, Reconversion, Show Unicode control characters. Insert Unicode control characters
Any ideas.
The cell editor using EditorWithText;
Version 11.2
Hi,
Those options are from the built-in context menu for the TextBox control - which the tree displays over a cell when in edit mode. The only way to change them is to replace the ContextMenu with one of your own.
can you provide a small sample on how to do that for an UltraTreeNodeCell ?
valuecell.AllowEdit = AllowCellEdit.Full; valuecell.ResetEditorControl();
var ed = new EditorWithText(); valuecell.Editor = ed;
/* what do I need to do here to set a context menu ?*/
You don't need the editor. What happens here is that when the editor goes into edit mode, it positions a TextBox control over the cell. So what I would do is set the ContextMenu or ContextMenuStrip on the UltraTree control itself. The control will handle copying this to the TextBox.You could do this in the BeforeEnterEditMode event and apply the appropriate context menu based on which cell is active and then clear it in the AfterExitEditMode event.
Tried it but not working as expected
as a test in the event I have
void ultraTree_pg_BeforeCellEnterEditMode(object sender, BeforeCellEnterEditModeEventArgs e)
{ this.ultraTree_pg.ContextMenu = new ContextMenu(); this.ultraTree_pg.ContextMenu.MenuItems.Add(new MenuItem("Test")); }
However, this menu only appears on cell that is not in edit mode (e.g. if I right-click on the cell with the label)
The cell with the Value ( In edit mode) still has the old Context menu appearing)
Regards
Ryan
Got it working. Have to use the AfterCellEnterEditMode
{
void ultraTree_pg_AfterCellEnterEditMode(object sender, AfterCellEnterEditModeEventArgs e) { var ed = e.Cell.EditorResolved; if (ed is EditorWithText) { var txt = ed as EditorWithText; txt.TextBox.ContextMenu = new ContextMenu(); txt.TextBox.ContextMenu.MenuItems.Add(new MenuItem("Test")); } }
}
Thanks for help
regards