Hi,
I am using RadControls for WinForms Q1 2011 and Visual Studio 2012, Ultimate Edition to develop a .NET4.0 app.
The app uses RadTreeView for showing a very simple file system explorer and removes nodes in two cases:
1. On NodeExpandedChanged the event handler removes a dummy node representing a collapsed directory with a new node.
This code works just fine.
2. On EventArrived fired by System.Management.ManagementEventWatcher upon CD insertion/ejection the event handler removes either a node representing the empty drive or a node representing the CD file system.
Currently I narrowed the code just to the attempt to remove a CD node
I tried different ways of removing the node, I tried wrapping the code with BeginUpdate()/EndUpdate(), I tried calling Invalidate() or Refresh() - the result is always the same
a) The node itself is still shown, although the debugger shows that the nodes count has decreased;
b) Expanding other nodes, e.g. a node representing C:\, does not work any more, i.e. the event is fired, but view remains unchanged.
Note: The only difference between the nodes removed in the cases #1 and #2 is that OnDirExpanded() removes only grandchildren or farther of the root node, while OnCdInsert() removes a child of the root node.
I am really lost and your help is my only hope now.
I am looking forward to your assistance and thank you in advance for it.
Best regards,
I am using RadControls for WinForms Q1 2011 and Visual Studio 2012, Ultimate Edition to develop a .NET4.0 app.
The app uses RadTreeView for showing a very simple file system explorer and removes nodes in two cases:
1. On NodeExpandedChanged the event handler removes a dummy node representing a collapsed directory with a new node.
private
void
OnDirExpandedChanged(
object
sender, RadTreeViewEventArgs e)
{
if
(e.Node.Expanded)
{
if
(e.Node.FirstNode.Name ==
"____dummy____"
)
{
m_fileExplorer.BeginUpdate();
RadTreeNode l_parent = e.Node.Parent;
int
l_nIx = e.Node.Index;
e.Node.Remove();
RadTreeNode l_new = CreateDirNode(
new
DirectoryInfo(e.Node.Name),
true
);
l_parent.Nodes.Insert(l_nIx, l_new);
l_new.Expand();
m_fileExplorer.EndUpdate();
}
}
}
// OnDirExpandedChanged
2. On EventArrived fired by System.Management.ManagementEventWatcher upon CD insertion/ejection the event handler removes either a node representing the empty drive or a node representing the CD file system.
Currently I narrowed the code just to the attempt to remove a CD node
private
void
OnCdInsert(
object
sender, EventArrivedEventArgs e)
{
ManagementBaseObject l_wmiDevice = (ManagementBaseObject) e.NewEvent[
"TargetInstance"
];
string
l_sDriveRootDir = l_wmiDevice[
"Name"
].ToString() + Path.DirectorySeparatorChar;
int
l_nIx = m_fileExplorer.Nodes[0].Nodes.IndexOf(l_sDriveRootDir);
m_fileExplorer.Nodes[0].Nodes[l_nIx].Remove();
// (1)
m_fileExplorer.Nodes[0].Nodes.Remove(l_sDriveRootDir);
// (2)
}
// OnCdInsert
a) The node itself is still shown, although the debugger shows that the nodes count has decreased;
b) Expanding other nodes, e.g. a node representing C:\, does not work any more, i.e. the event is fired, but view remains unchanged.
Note: The only difference between the nodes removed in the cases #1 and #2 is that OnDirExpanded() removes only grandchildren or farther of the root node, while OnCdInsert() removes a child of the root node.
I am really lost and your help is my only hope now.
I am looking forward to your assistance and thank you in advance for it.
Best regards,