Workaround: Instead of {RadTreeNode}.Nodes.Clear(), use while ({RadTreeNode}.Nodes.Count>0) { {RadTreeNode}.Nodes.RemoveAt(0); }
To reproduce: - Add a RadTreeView which have parent and child nodes to a form. - Expand nodes until the both scrollbars are simultaneously shown. - You will notice that you cannot scroll to the last item. Workaround: - Subscribe to the following ScrollerUpdated event handler: void Scroller_ScrollerUpdated(object sender, EventArgs e) { radTreeView1.TreeViewElement.InvalidateMeasure(); } - You can subscribe to this event with the following line of code: radTreeView1.TreeViewElement.Scroller.ScrollerUpdated += Scroller_ScrollerUpdated;
To reproduce: Add a RadTreeView to a form and use the following code: private List<EntityA> entities = new List<EntityA>(); public Form1() { InitializeComponent(); radTreeView1.TriStateMode = true; entities = new List<EntityA>(); for (int i = 0; i < 10; i++) { var newEntityI = new EntityA(i.ToString()); for (int j = 0; j < 100; j++) { var newEntityJ = new EntityB(j.ToString()); for (int k = 0; k < 1000; k++) { var newEntityK = new EntityC(k.ToString()); newEntityJ.Entities.Add(newEntityK); } newEntityI.Entities.Add(newEntityJ); } entities.Add(newEntityI); } } private void checkBox1_CheckedChanged(object sender, EventArgs e) { foreach (var node in radTreeView1.Nodes) { node.Checked = checkBox1.Checked; } } private void radTreeView1_NodesNeeded(object sender, NodesNeededEventArgs e) { if (e.Parent == null) { foreach (var entity in entities) { e.Nodes.Add(new RadTreeNode(entity.Name, false) { CheckState = ToggleState.Off, Tag = entity }); } } else if (e.Parent.Tag is EntityA) { var currentEntity = e.Parent.Tag as EntityA; foreach (var entity in currentEntity.Entities) { e.Nodes.Add(new RadTreeNode(entity.Name, false) { CheckState = e.Parent.CheckState, Tag = entity }); } } else if (e.Parent.Tag is EntityB) { var currentEntity = e.Parent.Tag as EntityB; foreach (var entity in currentEntity.Entities) { e.Nodes.Add(new RadTreeNode(entity.Name, false) { CheckState = e.Parent.CheckState, Tag = entity }); } } else if (e.Parent.Tag is EntityC) { } } Put a breakpoint in the last If statement, you will notice that the breakpoint is being hit, while it is not if the TrieStateMode is set to false Workaround: Use the following custom RadTreeNode: public class MyTreeNode : RadTreeNode { private FieldInfo triStateField; public MyTreeNode() : base() { } public MyTreeNode(string text) : base(text) { } public MyTreeNode(string text, RadTreeNode[] children) : base(text, children) { } public MyTreeNode(string text, bool expanded) : base(text, expanded) { } public MyTreeNode(string text, Image image) : base(text, image) { } public MyTreeNode(string text, Image image, bool expanded) : base(text, image, expanded) { } public override ToggleState CheckState { get { return base.CheckState; } set { bool set = false; if (this.TreeViewElement != null && this.TreeViewElement.TriStateMode) { if (this.triStateField == null) { this.triStateField = typeof(RadTreeViewElement).GetField("triStateMode", BindingFlags.Instance | BindingFlags.NonPublic); } triStateField.SetValue(this.TreeViewElement, false); set = true; } base.CheckState = value; if (set) { this.triStateField.SetValue(this.TreeViewElement, true); } } } }
Add e.Action in SelectedNodeChanging similar to the one in the standard TreeView.BeforeSelect event which indicates what caused the event - mouse click, key pressed, or other
To reproduce: Add a RadTreeView with hierarchical data. Select a node with hierarchy level > 0. Call the Clear method of the Nodes collection. Refill the tree, drag and drop a node, you will see that two nodes will be dropped since the previous node's Selected property is set to true. Workaround: private void DetachAllNodes(RadTreeNode parent) { this.CleanNode(parent); foreach (RadTreeNode node in parent.Nodes) { this.DetachAllNodes(node); } } private void CleanNode(RadTreeNode node) { node.Current = false; node.Selected = false; } foreach (RadTreeNode node in tree.Nodes) { this.DetachAllNodes(node); } tree.Nodes.Clear();
Workaround: this.radTreeView1.SelectedNode = null;
To reproduce: this issue is reproducible under Windows8 OS only -add RadTreeView from the Toolbox to the Form and add several tree nodes at design time; -add RadContextMenu from the Toolbox and add several items at design time; Use the following code: public Form1() { InitializeComponent(); this.radTreeView1.RadContextMenu = this.radContextMenu1; } -run the application; -select a tree node; -right mouse click over the node to show the context menu; As a result the main form looses focus and you are unable to click anywhere outside the RadTreeView. This issue is inconstant and it is not appearing every time. Workaround: use ContextMenu property instead: public Form1() { InitializeComponent(); ContextMenu menu = new ContextMenu(); foreach (var item in radContextMenu1.Items) { menu.MenuItems.Add(new MenuItem(item.Text)); } this.radTreeView1.ContextMenu = menu; // this.radTreeView1.RadContextMenu = this.radContextMenu1; }
To reproduce: Add a RadTreeView with some nodes and you will notice that the font is different than other controls. Workaround: void tree_NodeFormatting(object sender, TreeNodeFormattingEventArgs e) { e.NodeElement.ContentElement.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault; }
To reproduce: Add a RadTreeView ,add nodes, enable TriState, disable AutoCheckChildNodes and use this code: void cxTreeView2_NodeCheckedChanging(object sender, RadTreeViewCancelEventArgs e) { if (!cxTreeView2.AutoCheckChildNodes && cxTreeView2.CheckBoxes && cxTreeView2.TriStateMode) { cxTreeView2.TreeViewElement.NodeCheckedChanging -= cxTreeView2_NodeCheckedChanging; if (e.Node.CheckState == ToggleState.Indeterminate) { e.Cancel = true; e.Node.CheckState = ToggleState.On; CheckAllChildren(e.Node); } cxTreeView2.TreeViewElement.NodeCheckedChanging += cxTreeView2_NodeCheckedChanging; } } void CheckAllChildren(RadTreeNode parent) { foreach (var node in parent.Nodes) { node.CheckState = ToggleState.On; CheckAllChildren(node); } } Click a top node two times and remove the mouse from the checkbox, it is now showing as Indetermined but the data item is on. Workaround: void cxTreeView2_NodeCheckedChanging(object sender, RadTreeViewCancelEventArgs e) { if (!cxTreeView2.AutoCheckChildNodes && cxTreeView2.CheckBoxes && cxTreeView2.TriStateMode) { cxTreeView2.TreeViewElement.NodeCheckedChanging -= cxTreeView2_NodeCheckedChanging; if (e.Node.CheckState == ToggleState.Indeterminate) { e.Cancel = true; e.Node.CheckState = ToggleState.On; CheckAllChildren(e.Node); cxTreeView2.TreeViewElement.Update(RadTreeViewElement.UpdateActions.Reset); } cxTreeView2.TreeViewElement.NodeCheckedChanging += cxTreeView2_NodeCheckedChanging; } } void CheckAllChildren(RadTreeNode parent) { foreach (var node in parent.Nodes) { node.CheckState = ToggleState.On; CheckAllChildren(node); } }
An exception is thrown when changing the selection mode from Single to MultiSelect and then scrolling and selecting nodes.
To reproduce: - add a RadTreeView - enable multiselect - select at least 1 node - call radTreeView1.SelectedNodes.Clear() Workaround: Clear the nodes manually: foreach (var node in this.radTreeView1.SelectedNodes.ToList()) { node.Selected = false; }
To reproduce: private void btnFill_Click(object sender, EventArgs e) { radTreeView.BeginUpdate(); radTreeView.Nodes.Add(new RadTreeNode("root 1")); radTreeView.Nodes.Add(new RadTreeNode("root 2")); radTreeView.Nodes.Add(new RadTreeNode("root 3")); radTreeView.Nodes.Add(new RadTreeNode("root 4")); radTreeView.Nodes[radTreeView.Nodes.Count - 1].Expand(); for (int i = 0; i < 30; i++) { radTreeView.Nodes[radTreeView.Nodes.Count - 1].Nodes.Add(new RadTreeNode("text" +i)); } radTreeView.EndUpdate(); } private void radButton1_Click(object sender, EventArgs e) { radTreeView.BeginUpdate(); foreach (var node in radTreeView.Nodes[radTreeView.Nodes.Count - 1].Nodes.ToArray()) { node.Remove(); } for (int i = 0; i < 99; i++) { radTreeView.Nodes[radTreeView.Nodes.Count - 1].Nodes.Add(new RadTreeNode("aasdasd")); } radTreeView.EndUpdate(); } Workaround - reset the traverser and update the scroll value prior removing the nodes radTreeView.TreeViewElement.Scroller.Traverser.Reset(); this.treeView.TreeViewElement.Scroller.UpdateScrollValue();
To reproduce: radTreeView1.Filter = "new"; var node = new RadTreeNode( "test" ); radTreeView1.Nodes.Add( node ); //here the node is not in the Nodes collection if ( radTreeView1.Nodes.Contains( node ) == false ) { radTreeView1.Nodes.Add( new RadTreeNode( "test" ) ); } Workaround: remove the filter, perform the desired check and restore the filter
To reproduce: radTreeView1.Filter = "new"; radTreeView1.Nodes.Add("new Node"); for (int i = 0; i < 1000; i++) { radTreeView1.Nodes.Add(new RadTreeNode("test")); } Workaround: radTreeView1.TreeViewElement.Update(RadTreeViewElement.UpdateActions.Reset);
TreeViewDragDropService cannot be canceled on the following event: radTreeView1.TreeViewElement.DragDropService.PreviewDragOver
When a tree is bound using object-relational binding the editing does not work for nodes that are on level higher than the first.
FIX. RadTreeView - the tree should keep its selection, expanded nodes and scroll position when new record is added to its underlying data source
To reproduce: Add some nodes to a tree, and then clear them and move them to another tree. The inner nodes expand/collapse does not work correctly: void radButton1_Click(object sender, EventArgs e) { tree1.Nodes.Clear(); tree2.Nodes.AddRange(nodes); } RadTreeView tree1 = new RadTreeView(); RadTreeView tree2 = new RadTreeView(); List<RadTreeNode> nodes = new List<RadTreeNode>(); private void Populate(RadTreeView tree) { RadTreeNode n11 = new RadTreeNode("11"); RadTreeNode n12 = new RadTreeNode("12"); RadTreeNode n13 = new RadTreeNode("13"); RadTreeNode n14 = new RadTreeNode("14"); nodes.Add(n11); nodes.Add(n12); nodes.Add(n13); nodes.Add(n14); RadTreeNode n21 = new RadTreeNode("21"); RadTreeNode n22 = new RadTreeNode("22"); RadTreeNode n23 = new RadTreeNode("23"); RadTreeNode n24 = new RadTreeNode("24"); n11.Nodes.Add(n21); n11.Nodes.Add(n22); n11.Nodes.Add(n23); n11.Nodes.Add(n24); RadTreeNode n31 = new RadTreeNode("31"); RadTreeNode n32 = new RadTreeNode("32"); RadTreeNode n33 = new RadTreeNode("33"); RadTreeNode n34 = new RadTreeNode("34"); n21.Nodes.Add(n31); n21.Nodes.Add(n32); n21.Nodes.Add(n33); n21.Nodes.Add(n34); tree.Nodes.AddRange(nodes); } 1. Run 2. Expand all nodes in tree1 3. Select node 23 4. Press button move right 5. Click at "plus" at node 21. -> expand collapse does not work correctly Workaround - instead of calling the Clear method of the Nodes collection, remove them manually: while (tree1.Nodes.Count > 0) { tree1.Nodes.RemoveAt(0); }
RadTreeView - Traverser throws exception if you clear and recreate all sub nodes of some node. Steps to reproduce: 1. Create RadTreeView with one node. 2. Add 100 sub nodes. 3. Clear the sub nodes. 4. Move scroll. WorkAround: private void RefreshNodes() { radTreeView1.BeginUpdate(); this.radTreeView1.TreeViewElement.Scroller.Traverser.Position = groupNode; this.radTreeView1.TreeViewElement.Scroller.Traverser.Reset(); this.radTreeView1.SelectedNodes.Clear(); groupNode.Nodes.Clear(); AddNodes(groupNode.Nodes, 1, 100); groupNode.Expand(); radTreeView1.EndUpdate(); this.radTreeView1.TreeViewElement.Update(RadTreeViewElement.UpdateActions.Reset); }
If you have a node with a very long text that requires horizontal scrollbar and at the same time you have a many nodes which requires a vertical scrollbar in some border cases the long text of the node is cut off (with ellipsis).