To reproduce: use the attached sample project and follow the steps: 1. Filter by "Jo". 2. Press the "Refresh" button. 3. Press the "Clear Filter" button. Note: if there is no applied filter when rebinding, the nodes order is correct. Please refer to the attached gif file. Workaround: clear the filter before setting the DataSource property and restore ethe filter afterwards: string filter = this.radTreeView1.Filter + ""; this.radTreeView1.Filter = ""; this.radTreeView1.DataSource = dt; this.radTreeView1.DisplayMember = "Name"; this.radTreeView1.ValueMember = "Id"; this.radTreeView1.Filter = filter;
Error: "Object of type 'Telerik.WinControls.Enumerations.ToggleState' cannot be converted to type 'System.Boolean'." To reproduce: public Form1() { InitializeComponent(); List<Parent> dataItems = new List<Parent>(); Parent currentParent; Child currentChild; List<Child> children; string parentId = string.Empty; string childId = string.Empty; for (int i = 1; i <= 5; i++) { parentId = Guid.NewGuid().ToString(); children = new List<Child>(); for (int j = 1; j < 5; j++) { childId = Guid.NewGuid().ToString(); currentChild = new Child(childId, parentId, "SubNode." + i + "." + j, j % 2 == 0); children.Add(currentChild); } currentParent = new Parent(parentId, "Node." + i, i % 2 == 0,children); dataItems.Add(currentParent); } radTreeView1.DataSource = dataItems; radTreeView1.DisplayMember = "Title\\Name"; radTreeView1.ChildMember = "Parent\\Children"; radTreeView1.CheckedMember = "IsActive\\Status"; radTreeView1.CheckBoxes = true; } public class Parent { public string ParentId { get; set; } public string Title { get; set; } public bool IsActive { get; set; } public List<Child> Children { get; set; } public Parent(string parentId, string title, bool isActive, List<Child> children) { this.ParentId = parentId; this.Title = title; this.IsActive = isActive; this.Children = children; } } public class Child { public string ChildId { get; set; } public string ParentId { get; set; } public string Name { get; set; } public bool Status { get; set; } public Child(string childId, string parentId, string name, bool status) { this.ChildId = childId; this.ParentId = parentId; this.Name = name; this.Status = status; } } Workaround: Use a custom TypeConverter for the boolean properties: public class ToggleStateConverter : TypeConverter { public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return destinationType == typeof(ToggleState); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (value is bool) { switch ((bool)value) { case true: return ToggleState.On; case false: return ToggleState.Off; default : return ToggleState.Indeterminate; } } return base.ConvertTo(context, culture, value, destinationType); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(ToggleState); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { ToggleState state = (ToggleState)value; switch (state) { case ToggleState.On: return true; case ToggleState.Off: return false; case ToggleState.Indeterminate: return false; } return base.ConvertFrom(context, culture, value); } }
The check boxes are squeezed when the expanded state of the child nodes is changed in NodeCheckedChanged event. Possible workaround: use Begin-End update block
To reproduce: use the following code: public Form1() { InitializeComponent(); this.radTreeView1.MultiSelect = true; for (int i = 0; i < 3; i++) { RadTreeNode node = new RadTreeNode(); node.Text = "Node." + i; for (int j = 0; j < 3; j++) { node.Nodes.Add(new RadTreeNode("Node." + i + "." + j)); } this.radTreeView1.Nodes.Add(node); } this.radTreeView1.SelectedNodeChanged += radTreeView1_SelectedNodeChanged; } private void radTreeView1_SelectedNodeChanged(object sender, Telerik.WinControls.UI.RadTreeViewEventArgs e) { Console.WriteLine(e.Node.Text + ">> Selected: " + e.Node.Selected); } 1.Select a node 2.Press Ctrl and click over the selected node again in order to unselect it. The SelectedNodeChanged event will not fire. Workaround: public class MyRadTreeNode : RadTreeNode { public MyRadTreeNode(string text) : base(text) { } private static readonly MethodInfo OnSelectedNodeChangedMethodInfo = typeof(RadTreeViewElement).GetMethod("OnSelectedNodeChanged", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(RadTreeNode), typeof(RadTreeViewAction) }, null); protected override void OnNotifyPropertyChanged(PropertyChangedEventArgs args) { base.OnNotifyPropertyChanged(args); if (args.PropertyName == "Selected" && TreeViewElement != null) { OnSelectedNodeChangedMethodInfo.Invoke(TreeViewElement, new object[] { this, RadTreeViewAction.ByMouse }); } } }
Workaround: private void radTreeView1_NodeFormatting(object sender, Telerik.WinControls.UI.TreeNodeFormattingEventArgs e) { e.NodeElement.UseDefaultDisabledPaint = true; }
In Load-On-Demand scenario when visibility of ExpanderElement is changed in NodeFormatting - drawing of lines is invalid
To reproduce: - Open the attached project. - Scroll to the right. - Drag a node. - The DropHint line is outside the window. Workaround: class CustomTreeView : RadTreeView { //Replace the default element with the custom one protected override RadTreeViewElement CreateTreeViewElement() { return new CustomTreeViewElement(); } //Enable theming for the control public override string ThemeClassName { get { return typeof(RadTreeView).FullName; } } } class CustomTreeViewElement : RadTreeViewElement { //Enable themeing for the element protected override Type ThemeEffectiveType { get { return typeof(RadTreeViewElement); } } //Replace the default drag drop service with the custom one protected override TreeViewDragDropService CreateDragDropService() { return new MyDragDropService(this); } } class MyDragDropService : TreeViewDragDropService { public MyDragDropService(RadTreeViewElement owner) : base(owner) { } protected override void UpdateHintPosition(Point mousePosition) { base.UpdateHintPosition(mousePosition); RadLayeredWindow dropHint =typeof(TreeViewDragDropService).GetField("dropHintWindow", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(this) as RadLayeredWindow; if (dropHint != null) { TreeNodeElement nodeElement = this.DropTarget as TreeNodeElement; dropHint.Location = new Point (nodeElement.ElementTree.Control.PointToScreen(Point.Empty).X, dropHint.Location.Y); } } }
To reproduce: 1. Drag and drop RadTreeView on the form. 2. Set the Dock property to true 3. Add 3 or more nodes with long names 4. Resize the form to minimum size and you will notice that the spacing between characters is changed. Workaround: If FontSize of nodes is bigger than 13, you can subscribe to the NodeFormatting event and set the AutoEllipsis property to false: Font font = new Font("Segoe UI", 13f, FontStyle.Regular); void radTreeView1_NodeFormatting(object sender, Telerik.WinControls.UI.TreeNodeFormattingEventArgs e) { e.NodeElement.ContentElement.Font = font; e.NodeElement.ContentElement.AutoEllipsis = false; } If font size is smaller, you need to set the MinSize property too: Font font = new Font("Segoe UI", 12f, FontStyle.Regular); void radTreeView1_NodeFormatting(object sender, Telerik.WinControls.UI.TreeNodeFormattingEventArgs e) { e.NodeElement.ContentElement.Font = font; e.NodeElement.ContentElement.MinSize = new System.Drawing.Size(500, 18); }
To reproduce: Bind the tree to the following structure: public class DeskSites { public string DeskSiteName { get; set; } public Channels channels { get; set; } } public class Channels : List<Channel> { } public class Channel { public string ChannelName { get; set; } public FileSets fileSets { get; set; } } public class FileSets : List<FileSet> { } public class FileSet { public string FileSetName { get; set; } } Workaround: Use the the generic class instead of the inherited one: public class DeskSites { public string DeskSiteName { get; set; } public List<Channel> channels { get; set; } }
To reproduce: 1. Add a RadTreeView with several nodes 2. Subscribe to the EditorRequired event and specify the editor to TreeViewTextBoxEditor where its Multiline property is set to true. 3. Select a node and press F2. The editor is activated. However, when you enter some text and press Ctrl+Enter, the editor is closed. The expected behavior is that a new line is inserted. Workaround: private void radTreeView1_EditorRequired(object sender, TreeNodeEditorRequiredEventArgs e) { CustomTreeViewTextBoxEditor editor = new CustomTreeViewTextBoxEditor(); editor.Multiline = true; e.Editor = editor; } public class CustomTreeViewTextBoxEditor : TreeViewTextBoxEditor { protected override void OnKeyDown(KeyEventArgs e) { if (e.KeyCode == Keys.Enter && e.Modifiers == Keys.Control && this.Multiline) { return; } base.OnKeyDown(e); } }
Select Demo application >> "Tree View" -> "Drag & Drop". Focus on the left treeview. 1. Click on the node "Drafts"; 2. Press Shift button and click on the "Outbox" node; 3. Release shift button; 4. Press left mouse button on the "Outbox" node and start dragging; 5. Drop selected nodes after node "Large Mail". You can see that order of nodes was changed. Before: "Drafts", "Inbox" and "Outbox" After: "Outbox", "Drafts" and "Inbox" Possible workaround: http://www.telerik.com/forums/nodes-order-after-drag-drop#5bbz6cBDEUeHLyLU5zkfDQ
To reproduce: Add some notes to RadTreeView. Set the Font as follows in the NodeFormatting event: Font font = new Font("Tahoma", 13f); void tree_NodeFormatting(object sender, TreeNodeFormattingEventArgs e) { e.NodeElement.ContentElement.Font = font; } Start the project on Windows 7 or Vista with ClearType off and you will see that the font is thick. Workaround: Use the following node element: public class MyTreeNodeElement : TreeNodeElement { protected override TreeNodeContentElement CreateContentElement() { return new MyTreeNodeContentElement(); } protected override Type ThemeEffectiveType { get { return typeof(TreeNodeElement); } } } public class MyTreeNodeContentElement : TreeNodeContentElement { protected override void PrePaintElement(Telerik.WinControls.Paint.IGraphics graphics) { base.PrePaintElement(graphics); Graphics g = graphics.UnderlayGraphics as Graphics; if (g == null) { return; } if (this.Enabled) { g.TextRenderingHint = this.TextRenderingHint; } else { g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; } } } void tree_CreateNodeElement(object sender, CreateTreeNodeElementEventArgs e) { e.NodeElement = new MyTreeNodeElement(); } And set the TextRenderingHint of the ContentElement: Font font = new Font("Tahoma", 13f); void tree_NodeFormatting(object sender, TreeNodeFormattingEventArgs e) { e.NodeElement.ContentElement.Font = font; e.NodeElement.ContentElement.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; }
To reproduce: Use the following code on an empty RadTreeView: this.TreeView.AddNodeByPath("General\\Billing\\February\\Report.txt"); You will see that the Report.txt node will be added to the Root node Workaround: Use the following method: private RadTreeNodeCollection AddNode(string path) { if (path == String.Empty) return this.TreeView.Nodes; string node = Path.GetFileName(path); RadTreeNodeCollection parent = AddNode(Path.GetDirectoryName(path)); if (parent.Contains(node)) return parent[node].Nodes; else return parent.Add(node).Nodes; }
To reproduce: Add nodes to RadTreeView with at least 3 levels hierarchy. Set some of the last level nodes Visible property to false. Start the application. Expand some nodes and scroll. You will notice that the last item will change sometimes. Workaround: Set this.radTreeView1.TreeViewElement.AllowArbitraryItemHeight = true; Use ItemHeight = 1, instead of Visible = false
The Enabled property cannot be set in PropertyBuild if the RadTreeView is already data-binded via Property builder Workaround: Set the property at run-time.
Workaround: private void radTreeView1_NodeFormatting(object sender, TreeNodeFormattingEventArgs e) { e.NodeElement.ContentElement.TextAlignment = ContentAlignment.MiddleCenter; }
To reproduce: Add a RadTreeView and a Timer(from the Windows.Forms namespace). Set the timer's interval to some short duration and add nodes to tree on its tick event. Scroll the thumb while the timer is ticking. At some point you will notice that the scrollbar's maximum value is not correct. Workaround: Do not add nodes while scrolling: List<string> cachedValues = new List<string>(); System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer() { Interval = 100 }; void radTreeView1_MouseCaptureChanged(object sender, EventArgs e) { timer.Start(); } void timer_Tick(object sender, EventArgs e) { timer.Stop(); if (this.cachedValues.Count > 0 && !radTreeView1.TreeViewElement.Scroller.Scrollbar.ThumbElement.Capture) { foreach (string value in this.cachedValues) { root.Nodes.Add(value); } cachedValues.Clear(); } } private void timerUpdateNodes_Tick(object sender, EventArgs e) { for (int i = 0; i < 10; ++i) { if (random.NextDouble() < .2) { if (radTreeView1.TreeViewElement.Scroller.Scrollbar.ThumbElement.Capture) { cachedValues.Add("Node"); } else { root.Nodes.Add("Node"); } } } }
Copy and paste in RadTreeView does not copies all properties of RadTreeNode.
The child nodes are aligned to the root nodes when ShowRootLines property is set to false.
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);