Copyright Accelerated Ideas 2007 Legacy Blog Posts | Blog Home | .NET Components

AIDirectoryViewer – Responding to the folder click event


1/2/2007

Developers should respond to the FolderNodeClick event which is raised when the end user clicks a specific node in the Directory Viewer.

This event passes the default TreeNodeMouseClickEventArgs object. Developers can use this object to translate the Node into a DirectoryInfo object by calling:

aiDirectoryViewer1.GetFolderFromNode(e.Node)


Our demo uses the following example code to find the name, path and access times of the selected Folder affected by the click event:

private void aiDirectoryViewer1_FolderNodeClicked(object sender, TreeNodeMouseClickEventArgs e)
{
DirectoryInfo aInfo = aiDirectoryViewer1.GetFolderFromNode(e.Node);
tbName.Text = aInfo.Name;
tbPath.Text = aInfo.FullName;
tbModDate.Text = aInfo.LastAccessTime.ToShortDateString();
if (aInfo.Parent != null)
tbParentFol.Text = aInfo.Parent.Name;
else
tbParentFol.Text = \"None\";
}


< Blog Home