How to reproduce:
DataTable table = new DataTable();
table.Columns.Add("ParentId", typeof(int));
table.Columns.Add("ChildId", typeof(int));
table.Columns.Add("ProductId", typeof(int));
table.Columns.Add("ProductCode", typeof(string));
table.Rows.Add(0, 1, 3, "Pr - 01");
table.Rows.Add(1, 2, 4, "P r- 02");
table.Rows.Add(1, 3, 5, "Pr - 03");
this.radTreeView1.DisplayMember = "ProductCode";
this.radTreeView1.ParentMember = "ParentId";
this.radTreeView1.ChildMember = "ChildId";
this.radTreeView1.ValueMember = "ProductId";
this.radTreeView1.DataSource = table;
Add a RadTreeView and fill it with nodes so that a vertical scrollbar is shown.
The RadTreeView.TopNode property indicates that it is expected to return the RadTreeNode which visual node element is the first visible one in the current view. But it always return the first data node in RadTreeView no matter which node is currently visible at the top. This is because it consider the RadTreeNode.Visible property.
Workaround:
TreeNodeElement neFirstVisible = this.radTreeView1.TreeViewElement.ViewElement.Children[0] as TreeNodeElement;
RadMessageBox.Show("TopNode = " + neFirstVisible.Data.Text);
Please run the attached sample project and follow the steps illustrated in the gif file. You will notice the following behavior:
If you select multiple items/nodes and then right click on the last selected item/node, the context menu comes up as expected and multiple selection is kept. But if you right click on any other item/node that is selected,the selected nodes become unselected and only the node you are over becomes selected.
The multiple selection is kept in Windows Explorer and VS Solution explorer wne you right click over an already selected node.
Workaround:
public RadForm1()
{
InitializeComponent();
this.radTreeView1.MultiSelect = true;
this.radTreeView1.AllowDefaultContextMenu = true;
}
class CustomTreeViewElement : RadTreeViewElement
{
protected override Type ThemeEffectiveType
{
get
{
return typeof(RadTreeViewElement);
}
}
protected override bool ProcessMouseDown(MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
RadContextMenu menu = this.ContextMenu;
RadTreeNode node = this.GetNodeAt(e.Location);
if (node!=null)
{
node.Selected = true;
}
if (node != null && node.ContextMenu != null)
{
menu = node.ContextMenu;
}
if (menu == null && this.AllowDefaultContextMenu)
{
menu = this.InitializeDefaultContextMenu(node);
}
if (menu != null)
{
RadControl parentControl = (this.ElementTree.Control as RadControl);
if (parentControl != null)
{
menu.ThemeName = parentControl.ThemeName;
menu.DropDown.RightToLeft = parentControl.RightToLeft;
}
TreeViewContextMenuOpeningEventArgs args = new TreeViewContextMenuOpeningEventArgs(node, menu, this);
OnContextMenuOpening(args);
if (!args.Cancel)
{
menu.Show(this.ElementTree.Control, e.Location);
return true;
};
}
}
return base.ProcessMouseDown(e);
}
}
class CustomTreeView : RadTreeView
{
protected override RadTreeViewElement CreateTreeViewElement()
{
return new CustomTreeViewElement();
}
public override string ThemeClassName
{
get
{
return typeof(RadTreeView).FullName;
}
}
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x7b:
return;
}
base.WndProc(ref m);
}
}
Add a CodedUI test which records expanding a node in RadTreeView. Run the CodedUI test and you will see that the TestMethod throws the following exception:
"Microsoft.VisualStudio.TestTools.Extension.UITestControlNotFoundException: The playback failed to find the control with given search properties."
Sub New()
InitializeComponent()
Me.RadTreeView1.Nodes.Clear()
Me.RadTreeView1.CheckBoxes = True
Dim node = New RadTreeNode("1") With {.CheckType = CheckType.CheckBox, .Checked = True, .CheckState = ToggleState.Indeterminate}
RadTreeView1.Nodes.Add(node)
node.Nodes.Add(New RadTreeNode("1.1") With {.CheckType = CheckType.RadioButton, .Checked = True, .CheckState = ToggleState.Indeterminate})
node.Nodes.Add(New RadTreeNode("1.2") With {.CheckType = CheckType.RadioButton})
node.Nodes.Add(New RadTreeNode("1.3") With {.CheckType = CheckType.RadioButton})
node = New RadTreeNode("2") With {.CheckType = CheckType.CheckBox, .Checked = True, .CheckState = ToggleState.Indeterminate}
RadTreeView1.Nodes.Add(node)
RadTreeView1.Nodes.Add(New RadTreeNode("3"))
End Sub
Workaround:
Sub New()End Sub
Greetings,
While testing the exporting feature of RadTreeView, I noticed the following issue :
Using the code below , everything works just fine :
Me
.RadTreeView1.RightToLeft = System.Windows.Forms.RightToLeft.Yes
Dim
exporter
As
TreeViewSpreadExport =
New
TreeViewSpreadExport(
Me
.RadTreeView1)
AddHandler
exporter.CellFormatting,
AddressOf
exporter_CellFormatting
exporter.ExportFormat = SpreadExportFormat.Xlsx
exporter.ExportVisualSettings =
False
exporter.ExportImages =
False
exporter.ExportChildNodesGrouped =
True
exporter.CollapsedNodeOption = HiddenOption.ExportAlways
Dim
renderer
As
SpreadExportRenderer =
New
SpreadExportRenderer()
exporter.RunExport(
"D:\test.xlsx"
, renderer)
But, the following line of the code raises an error in a specific circumasntance (I describe it more, further in the thread) :
exporter.RunExport(
"D:\test.xlsx"
, renderer)
Error Screenshot is attached : 1.jpg
Details about the error :
System.ArgumentOutOfRangeException
HResult=0x80131502
Message=value should be greater or equal than 0 and less or equal than 7.
Parameter name: value
Source=Telerik.Windows.Documents.Spreadsheet
StackTrace:
at Telerik.WinControls.UI.RadButtonBase.buttonElement_Click(
Object
sender, EventArgs e)
at Telerik.WinControls.RadElement.OnClick(EventArgs e)
at Telerik.WinControls.UI.RadButtonElement.OnClick(EventArgs e)
at Telerik.WinControls.RadElement.DoClick(EventArgs e)
at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at Telerik.WinControls.RadControl.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(
String
[] commandLine)
The Specific Circumstance :
In my RadTreeView's NodeMouseClick , I add some child nodes to the node which is clicked, at runtime :
Dim
_Node1
As
RadTreeNode = e.Node.Nodes.Add(
"Node 1"
)
Dim
_Node2
As
RadTreeNode = e.Node.Nodes.Add(
"Node 2"
)
Dim
_Node3
As
RadTreeNode = e.Node.Nodes.Add(
"Node 3"
)
Then I found out that setting "exporter.ExportChildNodesGrouped" to True causes the error. But if it is set to false, no error raised even in the above Circumstance.
P.S Normally setting "exporter.ExportChildNodesGrouped" to True or False doesn't cause any error, but adding some child nodes at run time surly does.
Thanks for your attention.
I've got a tree with multiple nodes like
document1
-page 1
-page 2
document1
-page 1
-page 2
-page 3
...
document10
-page 1
-page 2
Due to the size of the treeview, only 2 or 3 documents are on screen, the rest is scrolled. (manually added items, no dynamic or lazy loading)
Lets say I click page 2 of document one, hold the mouse button to select more and go down to the last document (the tree is automatically scrolled down, as expected)
But when I go back to review what I selected, only the last items on screen are selected (documents 9 and 10 for example).
When I try to do the same selection with the arrow keys and the shift key, it works fine, but not with the mouse.
Hello,
I use radbreadcrumb as a group path explorer in my software.
I associate it with a treeview. Please see the attache photos.
When I select a treeviewitem which has too much parent levels, the radbreadcrumb can not display the path completely.
I've tried autoscrollmargin and autoscrollminsize. No luck. Because my radbreadcrumb is in a splitcontainerpanel, the display size is changeable.
I expect a custom function can act like Windows Explorer (see the last attach photo). When there is no enough display space, only the last levels are shown.
PS. I've integrated the telerik solution from this post. And it works great.
https://www.telerik.com/forums/getting-breadcrumb-to-act-like-windows-explorer-breadcrumb
Thank you by advance.
Kun
Hi there
I found this issue in RadTreeView filtering
I have a 2-level text structure programmatically created
after creation I use the command
radtree.ExpandAll()
This is the only event handled
Private Sub txtFilter_TextChanged(sender As Object, e As EventArgs) Handles txtFilter.TextChanged
radtreeNavigazione.Filter = txtFilter.Text
End Sub
When I set a filter with at least 4 letters and then I select the text in the filter box and press "back", the app freezes with cpu working at 50 %.
I use this workaround to solve
Private Sub txtFilter_TextChanged(sender As Object, e As EventArgs) Handles txtFilter.TextChanged
radtreeNavigazione.Filter = txtFilter.Text
End Sub
I use this workaround
Private Sub txtFilter_TextChanged(sender As Object, e As EventArgs) Handles txtFilter.TextChanged
radtree.CollapseAll()
radtreeNavigazione.Filter = txtFilter.Text
radtree.ExpandAll()
End Sub
In this way it works, but I wanted to report the issue.
Thank you in advance for your attention
Hi All,
I have made User control for custom node, in this user control i have used following controls
1 RadLabel (no of control - 3)
2 RadPanel (no of control -1)
3 PictureBox (no of Control - 4 )
4 TableLayoutPanel (no of control -3)
Means i have used total 11 controls within my user control.
Height of usercontrol = 146
Width of Usercontrol = 595
I have taken RadTreeView and above UserControl added as Node,following properties of treeview is set
this.radTreeView1.DataSource = Staff.GetStaff();
this.radTreeView1.ParentMember = "ParentID";
this.radTreeView1.ChildMember = "ID";
this.radTreeView1.DisplayMember = "Department";
this.radTreeView1.CreateNodeElement += this.OnCreateNodeElement;
this.radTreeView1.TreeViewElement.AutoSizeItems = true;
this.radTreeView1.ShowRootLines = false;
this.radTreeView1.FullRowSelect = false;
this.radTreeView1.ShowLines = true;
this.radTreeView1.LineStyle = TreeLineStyle.Solid;
this.radTreeView1.LineColor = Color.FromArgb(110, 153, 210);
this.radTreeView1.TreeIndent = 50;
this.radTreeView1.ExpandAll();
But when i run the code it shows like this means my control is not displaying and the property "AutoSizeItems" is not working.
hope for quick reply
Hi all,
RadTreeView is very nice control , For treeline we can give line style, color but we can't set line thickness,
I want to change thickness of Treeline can you guide me how to do it?
Afternoon
We have a RadTReeView that we drag nodes around to reorder within the same treeview.
There are about 2000 nodes in the tree that is a self referencing data bound and goes about 15 levels deep at some parts of the tree
When we click left mouse down (keeping it down) to drag and drop reorder a node, using the mouse wheel to scroll the tree up or down does not work anymore
We want to for instance drag a node from a location to another location outside the current view, using the mouse wheel to navigate the tree view up and down. This used to work, but not after upgrading to the new 2019 telerik.
Is there a tree view control option that needs to be toggled for this to work?
Thank you
Theo
Hi there, through out our app we use the treeview everywhere - but we have had this issue where it crashes when someone right clicks on the treeview where there is no node. This crash happens on the "ContextMenuOpening" event when we try to use e.TreeElement. This is because, on the telerik side of things, the getter for that property is throwing a NullReferenceException (see attached screenshot)
I think this is happening because in your RadTreeViewCancelEventArgs.cs it is this:
public RadTreeViewElement TreeElement
{
get { return node.TreeViewElement; }
}
public RadTreeView TreeView
{
get { return node.TreeView; }
}
But since node == null, it throws the exception. It probably should check for null, and if node is null, return a null for those properties - so we can use null conditional operator to check stuff. We have a workaround but it is just lots of copy and paste of things.
To reproduce: add a RadTreeView and a RadBreadCrumb and apply the MaterialTeal theme. Refer to the attached screenshot illustrating the wrong font of the selected item. Workaround: public partial class RadForm1 : Telerik.WinControls.UI.RadForm { public RadForm1() { InitializeComponent(); ThemeResolutionService.ApplicationThemeName = "MaterialTeal"; this.radTreeView1.NodeFormatting += radTreeView1_NodeFormatting; this.radTreeView1.SelectedNodeChanged += radTreeView1_SelectedNodeChanged; } private void UpdateFont() { foreach (RadSplitButtonElement item in this.radBreadCrumb1.BreadCrumbElement.Items) { foreach (RadMenuItem menuItem in item.Items) { if (this.radTreeView1.SelectedNode != null && menuItem.Text == this.radTreeView1.SelectedNode.Text) { menuItem.Font = new Font(f.FontFamily,f.Size, FontStyle.Bold); } } } } private void radTreeView1_SelectedNodeChanged(object sender, Telerik.WinControls.UI.RadTreeViewEventArgs e) { UpdateFont(); } Font f = null; private void radTreeView1_NodeFormatting(object sender, Telerik.WinControls.UI.TreeNodeFormattingEventArgs e) { f = e.NodeElement.ContentElement.Font; }
To reproduce: Run the attached application. Drag Node 2 to after Node 4 while holding down the Alt key. Note that the Node 2 copy is inserted before Node 4. When Node 2 is dragged to after Node 4 without holding down the Alt key, Node 2 is correctly moved to after Node 4. Workaround: you can modify the TreeViewDragDropService and control at what position exactly to be inserted the dragged node: https://docs.telerik.com/devtools/winforms/treeview/drag-and-drop/modify-the-dragdropservice-behavior https://docs.telerik.com/devtools/winforms/treeview/drag-and-drop/drag-and-drop-in-bound-mode
To reproduce: please refer to the attached sample project and try to reorder a node. You will notice that the message box is not rendered properly. //case 2 private void DragDropService_PreviewDragDrop(object sender, RadDropEventArgs e) { e.Handled = true; RadMessageBox.Show(this, "Showing a messagebox under dragending doesn't work correctly."); } //case 1 private void radTreeView1_DragEnding(object sender, Telerik.WinControls.UI.RadTreeViewDragCancelEventArgs e) { //e.Cancel = true; //RadMessageBox.Show(this, "Showing a messagebox under dragending doesn't work correctly."); } Workaround: subscribe to the TreeViewElement.DragDropService.PreviewDragDrop and set the Handled argument to true if you want to cancel the drop operation. Then, handle the TreeViewElement.DragDropService.Stopped event and show the desired message. public Form1() { InitializeComponent(); this.radTreeView1.TreeViewElement.DragDropService.PreviewDragDrop += DragDropService_PreviewDragDrop; this.radTreeView1.TreeViewElement.DragDropService.Stopped+=DragDropService_Stopped; } private void DragDropService_Stopped(object sender, EventArgs e) { RadMessageBox.Show(this, "Showing a messagebox under dragending doesn't work correctly."); } private void DragDropService_PreviewDragDrop(object sender, RadDropEventArgs e) { e.Handled = true; }