To reproduce: private void Form1_Load(object sender, EventArgs e) { this.radTreeView1.Nodes.Add("Node1"); this.radTreeView1.Nodes.Add("Node2"); this.radTreeView1.Nodes.Add("Node3"); this.radTreeView1.Nodes.Add("Node4"); this.radTreeView1.Nodes.Add("Node5"); this.radTreeView1.Nodes.Add("Node6"); this.radTreeView1.Nodes["Node1"].Nodes.Add("Node11"); this.radTreeView1.Nodes["Node1"].Nodes.Add("Node12"); this.radTreeView1.Nodes["Node1"].Nodes.Add("Node13"); this.radTreeView1.Nodes["Node1"].Nodes.Add("Node14"); this.radTreeView1.Nodes["Node2"].Nodes.Add("Node21"); this.radTreeView1.Nodes["Node2"].Nodes.Add("Node22"); this.radTreeView1.Nodes["Node2"].Nodes.Add("Node23"); this.radTreeView1.Nodes["Node2"].Nodes.Add("Node24"); this.radTreeView1.Nodes["Node3"].Nodes.Add("Node31"); this.radTreeView1.Nodes["Node3"].Nodes.Add("Node32"); this.radTreeView1.Nodes["Node3"].Nodes.Add("Node33"); this.radTreeView1.Nodes["Node3"].Nodes.Add("Node34"); this.radTreeView1.Nodes["Node4"].Nodes.Add("Node41"); this.radTreeView1.Nodes["Node4"].Nodes.Add("Node42"); this.radTreeView1.Nodes["Node4"].Nodes.Add("Node43"); this.radTreeView1.Nodes["Node4"].Nodes.Add("Node44"); this.radTreeView1.Nodes["Node5"].Nodes.Add("Node51"); this.radTreeView1.Nodes["Node5"].Nodes.Add("Node52"); this.radTreeView1.Nodes["Node5"].Nodes.Add("Node53"); this.radTreeView1.Nodes["Node5"].Nodes.Add("Node54"); this.radTreeView1.Nodes["Node6"].Nodes.Add("Node61"); this.radTreeView1.Nodes["Node6"].Nodes.Add("Node62"); this.radTreeView1.Nodes["Node6"].Nodes.Add("Node63"); this.radTreeView1.Nodes["Node6"].Nodes.Add("Node64"); } Workaround: add the nodes in the form's constructor. Second workaround: Me.RadTreeView1.TreeViewElement.Update(Telerik.WinControls.UI.RadTreeViewElement.UpdateActions.Reset)
To reproduce: - Bind to object-relational data - Add node via the context menu. - The DataBoundItem in the NodeAdding and NodeAdded events is null. Workaround: - Add the node in the code behind: private void RadTreeView1_NodeAdding(object sender, RadTreeViewCancelEventArgs e) { e.Cancel = true; RadTreeNode node = radTreeView1.SelectedNode; if (node.Level == 0) { data.Add(new MyParentClass() { Text = "test" }); } }
To reproduce: 1) Create a Windows Forms project. 2) Add a RadTreeView control. 3) Set the KeyboardSearchEnabled property to true. 4) Run the application and click in the tree (just to make sure it has the focus). 5) Using the keyboard, press a letter key. 6) Minimize the application. The same exception occurs if there are no selected nodes. Workaround: class MyTreeView : RadTreeView { protected override RadTreeViewElement CreateTreeViewElement() { return new MyTreeViewElement(); } public override string ThemeClassName { get { return typeof(RadTreeView).FullName; } set { base.ThemeClassName = value; } } } class MyTreeViewElement : RadTreeViewElement { protected override Type ThemeEffectiveType { get { return typeof(RadTreeViewElement); } } protected override RadTreeNode GetFirstMatch(string searchCriteria, RadTreeNodeCollection nodes) { if(this.SelectedNode == null && this.Items == null) { return null; } return base.GetFirstMatch(searchCriteria, nodes); } }
When you open the last node for edit programmatically, either an exception is thrown or the editor is not opened. Steps to reproduce: 1. Drag a RadTreeView from Toolbox and drop it onto the form. 2. Set the size of RadTreeView at design time to Size(354, 248). 3. Add a RadButton. 4. Use the following code: public Form1() { InitializeComponent(); radTreeView1.AllowEdit = true; radTreeView1.Nodes.Add("Root"); for (int i = 0; i < 20; i++) { radTreeView1.Nodes[0].Nodes.Add("Test" + i.ToString()); } } private void radButton1_Click(object sender, EventArgs e) { RadTreeNode node = new RadTreeNode("Demo" + radTreeView1.Nodes[0].Nodes.Count.ToString()); radTreeView1.Nodes[0].Nodes.Add(node); node.BeginEdit(); } 5. Click the button. 6. Collapse the root node. 7. Click the button again. Workaround: private void button1_Click(object sender, EventArgs e) { RadTreeNode node = new RadTreeNode("Demo" + radTreeView1.Nodes[0].Nodes.Count.ToString()); radTreeView1.Nodes[0].Nodes.Add(node); this.radTreeView1.TreeViewElement.Update(RadTreeViewElement.UpdateActions.Reset); node.Parent.Expanded = true; ((MyTreeViewElement)this.radTreeView1.TreeViewElement).SuspendEndEdit = true; node.BeginEdit(); ((MyTreeViewElement)this.radTreeView1.TreeViewElement).SuspendEndEdit = false; } public class MyTreeView : RadTreeView { protected override RadTreeViewElement CreateTreeViewElement() { return new MyTreeViewElement(); } public override string ThemeClassName { get { return typeof(RadTreeView).FullName; } set { } } } public class MyTreeViewElement : RadTreeViewElement { public bool SuspendEndEdit = false; protected override Type ThemeEffectiveType { get { return typeof(RadTreeViewElement); } } protected override bool EndEditCore(bool commitChanges) { if (SuspendEndEdit) { return false; } return base.EndEditCore(commitChanges); } }
To reproduce: public Form1() { InitializeComponent(); this.radTreeView1.NodesNeeded+=radTreeView1_NodesNeeded; } private void radTreeView1_NodesNeeded(object sender, Telerik.WinControls.UI.NodesNeededEventArgs e) { Console.WriteLine("NodesNeeded"); } As a result StackOverFlowException is thrown. Workaround: Do not subscribe to the NodesNeeded event if the LazyMode property is set to false.
To reproduce: public Form1() { InitializeComponent(); this.radTreeView1.LazyMode = true; this.radTreeView1.NodesNeeded+=radTreeView1_NodesNeeded; } private void radTreeView1_NodesNeeded(object sender, Telerik.WinControls.UI.NodesNeededEventArgs e) { } Workaround: set the AllowArbitraryItemHeight property to true.
To reproduce: public BlankTreeView() { InitializeComponent(); RadContextMenu menu = new RadContextMenu(); RadMenuItem addItem = new RadMenuItem("Add"); addItem.Click += addItem_Click; menu.Items.Add(addItem); this.radTreeView1.RadContextMenu = menu; BindingList<ParentObject> items = new BindingList<ParentObject>(); for (int i = 0; i < 3; i++) { BindingList<ChildObject> subItems = new BindingList<ChildObject>(); for (int j = 0; j < 10; j++) { subItems.Add(new ChildObject(j,"SubNode" + i + "." + j)); } items.Add(new ParentObject(i ,"Node" + i,subItems)); } this.radTreeView1.DataSource = items; this.radTreeView1.DisplayMember = "Title\\Description"; this.radTreeView1.ChildMember = "ParentObject\\Children"; } private void addItem_Click(object sender, EventArgs e) { if (this.radTreeView1.SelectedNode != null) { if (this.radTreeView1.SelectedNode.Level == 0) { Random rand = new Random(); ParentObject dataItem = this.radTreeView1.SelectedNode.DataBoundItem as ParentObject; if (dataItem != null) { dataItem.Children.Add(new ChildObject(rand.Next(0, 100),"New Node")); } } } } public class ParentObject: INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } private int id; private string title; private BindingList<ChildObject> children; public int ID { get { return this.id; } set { this.id = value; OnPropertyChanged("ID"); } } public string Title { get { return this.title; } set { this.title = value; OnPropertyChanged("Title"); } } public BindingList<ChildObject> Children { get { return this.children; } set { this.children = value; OnPropertyChanged("Children"); } } public ParentObject(int iD, string title, BindingList<ChildObject> children) { this.ID = iD; this.Title = title; this.Children = children; } } public class ChildObject: INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private int id; private string description; public int ID { get { return this.id; } set { this.id = value; OnPropertyChanged("ID"); } } public string Description { get { return this.description; } set { this.description = value; OnPropertyChanged("Description"); } } public ChildObject(int iD, string description) { this.id = iD; this.description = description; } protected virtual void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } } Workaround: reset the TreeViewElement after adding the record: radTreeView1.TreeViewElement.Update(RadTreeViewElement.UpdateActions.Reset);
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;
Workaround: create a custom TreeNodeContentElement and override the Synchronize method public class MyTreeNodeContentElement : TreeNodeContentElement { protected override Type ThemeEffectiveType { get { return typeof(TreeNodeContentElement); } } public override void Synchronize() { TreeNodeElement treeNodeElement = NodeElement; if (treeNodeElement == null || treeNodeElement.Data == null || treeNodeElement.Data.TreeViewElement == null || treeNodeElement.Data.Text == null) { return; } this.Text = treeNodeElement.Data.Text; } } public class MyTreeNodeElement : TreeNodeElement { protected override TreeNodeContentElement CreateContentElement() { return new MyTreeNodeContentElement(); } protected override Type ThemeEffectiveType { get { return typeof(TreeNodeElement); } } } public partial class Form1 : Form { public Form1() { InitializeComponent(); this.radTreeView1.AllowEdit = true; this.radTreeView1.DisplayMember = "name"; this.radTreeView1.ParentMember = "pid"; this.radTreeView1.ChildMember = "id"; this.radTreeView1.DataSource = this.GetSampleData(); this.radTreeView1.CreateNodeElement += radTreeView1_CreateNodeElement; this.radTreeView1.ValueChanged += radTreeView1_ValueChanged; } private void radTreeView1_CreateNodeElement(object sender, Telerik.WinControls.UI.CreateTreeNodeElementEventArgs e) { e.NodeElement = new MyTreeNodeElement(); } private void radTreeView1_ValueChanged(object sender, Telerik.WinControls.UI.TreeNodeValueChangedEventArgs e) { this.UpdateDb(); } private void UpdateDb() { this.radTreeView1.DataSource = null; DataTable dt = this.GetSampleData(); this.radTreeView1.DataSource = dt; } private DataTable GetSampleData() { DataTable dt = new DataTable(); DataColumn dc = new DataColumn(); dc.ColumnName = "id"; dc.DataType = typeof(int); dt.Columns.Add(dc); DataColumn dc1 = new DataColumn(); dc1.ColumnName = "name"; dc1.DataType = typeof(string); dt.Columns.Add(dc1); DataColumn dc2 = new DataColumn(); dc2.ColumnName = "pid"; dc2.DataType = typeof(int); dt.Columns.Add(dc2); DataRow dr = dt.NewRow(); dr[0] = 0; dr[1] = "My Computer"; dr[2] = DBNull.Value; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = 1; dr[1] = @"C:\"; dr[2] = 0; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = 2; dr[1] = @"D:\"; dr[2] = 0; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = 3; dr[1] = "Program Files"; dr[2] = 1; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = 4; dr[1] = "Microsoft"; dr[2] = 3; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = 5; dr[1] = "Telerik"; dr[2] = 3; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = 6; dr[1] = "WINDOWS"; dr[2] = 1; dt.Rows.Add(dr); return dt; } }
To reproduce: private void radTreeView1_NodesNeeded(object sender, Telerik.WinControls.UI.NodesNeededEventArgs e) { for (int i = 0; i < 100; i++) { var node = new RadTreeNode("Test"+i); for (int j = 0; j < 10; j++) { node.Nodes.Add(new RadTreeNode("Sub")); } node.Expanded = true; e.Nodes.Add(node); } } Workaorund: private void radTreeView1_NodesNeeded(object sender, Telerik.WinControls.UI.NodesNeededEventArgs e) { radTreeView1.BeginUpdate(); for (int i = 0; i < 100; i++) { var node = new RadTreeNode("Test"+i); for (int j = 0; j < 10; j++) { node.Nodes.Add(new RadTreeNode("Sub")); } node.Expanded = true; e.Nodes.Add(node); } radTreeView1.EndUpdate(); }
Workaround: this.radTreeView1.EnableRadAccessibilityObjects = false;
To reproduce: - Add a lot of nodes to the tree (scrollbars must appear). - Use the following code to add nodes: public RadForm1() { InitializeComponent(); radTreeView1.AllowEdit = true; RadContextMenu menu = new RadContextMenu(); RadMenuItem add = new RadMenuItem(); add.Click += add_Click; add.Text = "add"; menu.Items.Add(add); radTreeView1.RadContextMenu = menu; } void add_Click(object sender, EventArgs e) { RadTreeNode node = radTreeView1.SelectedNode; var newNode = node.Nodes.Add("new node"); node.Expanded = true; radTreeView1.SelectedNode = newNode; radTreeView1.BeginEdit(); } - Add a node and scroll Workaround: public RadForm1() { InitializeComponent(); radTreeView1.TreeViewElement.VScrollBar.Scroll += VScrollBar_Scroll; radTreeView1.MouseWheel += TreeViewElement_MouseWheel; } void TreeViewElement_MouseWheel(object sender, MouseEventArgs e) { var radTreeView = sender as RadTreeView; if (radTreeView.IsEditing) { radTreeView.EndEdit(); } } void VScrollBar_Scroll(object sender, ScrollEventArgs e) { var radTreeView = (sender as RadScrollBarElement).ElementTree.Control as RadTreeView; if (radTreeView.IsEditing) { radTreeView.EndEdit(); } }
To reproduce: - Add items to the tree view (scrollbar must appear) - Add context menu item which adds a new node and puts it in edit mode. - Add a new node with the context menu item, scroll to the bottom, add item again. - Scroll up and add item one more time. Workaround: void treeView_EditorRequired(object sender, TreeNodeEditorRequiredEventArgs e) { e.Editor = new TreeViewTextBoxEditor(); }
To reproduce: radTreeView1.CheckBoxes = true; radTreeView1.TriStateMode = true; radTreeView1.AutoCheckChildNodes = true; RadTreeNode root = radTreeView1.Nodes.Add("Home"); root.Expanded = true; RadTreeNode node1 = new RadTreeNode("Minimal"); node1.CheckState = Telerik.WinControls.Enumerations.ToggleState.On; root.Nodes.Add(node1); Workaround: first add the node to the Nodes collection and only then set its CheckState
Workaround: After updating the binding source reset the data source of the tree this.radTreeView.DataSource = null; this.radTreeView.DataSource = this.MyBindingSource;
Workaround: add RadTreeNodes at run time.
To reproduce: public Form1() { InitializeComponent(); for (int i = 0; i < 20; i++) { this.radTreeView1.Nodes.Add("Node"+i); } this.radTreeView1.AllowEdit = true; } The attached gif file illustrates the steps. Workaround: this.radTreeView1.VScrollBar.ValueChanged+=VScrollBar_ValueChanged; private void VScrollBar_ValueChanged(object sender, EventArgs e) { this.radTreeView1.EndEdit(); }
To reproduce: public Form1() { InitializeComponent(); this.radTreeView1.AllowDragDrop = true; this.radTreeView2.AllowDragDrop = true; for (int i = 0; i < 5; i++) { this.radTreeView1.Nodes.Add("Node1." + i); this.radTreeView2.Nodes.Add("Node2." + i); } this.radTreeView1.ScreenTipNeeded += radTreeView1_ScreenTipNeeded; this.radTreeView2.ScreenTipNeeded += radTreeView1_ScreenTipNeeded; } RadOffice2007ScreenTipElement _screenTip = new RadOffice2007ScreenTipElement(); private void radTreeView1_ScreenTipNeeded(object sender, Telerik.WinControls.ScreenTipNeededEventArgs e) { _screenTip.CaptionLabel.Text = "Caption"; _screenTip.MainTextLabel.Text = "text"; _screenTip.AutoSize = true; e.Delay = 2000; e.Item.ScreenTip = _screenTip; } Steps: 1. Drag a node from the first RadTreeView to the other while the screen-tip is shown for the dragged node. 2. When the screen-tip is about to be hidden, the error occurs. Workaround: private void radTreeView1_DragStarting(object sender, RadTreeViewDragCancelEventArgs e) { if (_screenTip.IsElementVisible) { this.radTreeView1.Behavior.HideScreenTip(); } }
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 }); } } }