Treeview - Progress Bar or Warning

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 8 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
IanUoY
Posts: 91
Last visit: Wed Sep 20, 2023 2:44 am

Treeview - Progress Bar or Warning

Post by IanUoY »

Hi there

I'm populating a treeview with a selected (recursed) directory structure.

However, where the directory structure is somewhat large it can take a few seconds to display. I have a statusstrip where there is a progress option. Preferably I would like a progress bar, but not sure if this can be done as there is no knowledge of the number of folders (that I'm aware of) ahead of the recurse process, so I can't set min max etc.

At present, I've also got a label in the statusstrip, which after selecting the root folder, it displays a message "Retrieving folder etc". This is then set to "" after the call to the recursive function. Unfortunately, it seems to reset to "" even before the function call is completed. My After Select statement is as below:-

If ($treeview.SelectedNode.Name -ne $root.FullName)
{
$toolstripstatuslabel1.Text = "Retrieving folder structure for " + $treeview.SelectedNode.Name + " Please wait..."

# $treeview.ImageIndex = 0
$treeviewChildren.Nodes.Clear()
$global:childroot = Get-Item ($treeview.SelectedNode.Name)
$treeviewChildren.Nodes.Add($childroot.fullname, $childroot.name)
PopulateChildNodes($treeviewChildren.Nodes[$childroot.fullname])
$treeviewChildren.Nodes[$childroot.FullName].Expand()
$toolstripstatuslabel1.Text = ""
}

If I comment out the last line ie $toolstripstatuslabel1 = "", then the warning is displayed. If the recursive call takes some time ie PoplateChildNodes, why is the warning text cleared?

Any help on this, most appreciated.

If ProgressBar solution, even better.

Regards

Ian
User avatar
SAPIEN Support Forums
Posts: 945
Last visit: Thu Oct 22, 2015 1:10 pm

Treeview - Progress Bar or Warning

Post by SAPIEN Support Forums »

This is an automated post. A real person will respond soon.

Thank you for posting, ian.cope@york.ac.uk.

Here are some hints to help you get an accurate and complete answer to your question.

Ask in the best forum: If you asked in the wrong forum, just copy your question to the right forum.

Anticipate follow-up questions!

Did you remember to include the following?
  • 1. Product, version and build
    2. 32 or 64 bit product
    3. Operating system, e.g. Windows 7 64 bit.
    4. Attach a screenshot, if applicable
    5. Attach logs, crash reports, etc., in a ZIP file
If not, please take a moment to edit your original post or reply to this one.

*** Make sure you do not post any licensing information ***
User avatar
IanUoY
Posts: 91
Last visit: Wed Sep 20, 2023 2:44 am

Re: Treeview - Progress Bar or Warning

Post by IanUoY »

Just an update on this....decided that progress bar was never an option due to the fact I would have to determine number of folders first etc.

However, I discovered that setting the toolstripstatuslabel text was working correctly, but not displaying unless I refreshed the form after setting the text. This only seems to happen when it is set as part of the Treeview_AfterSelect event.....is this a bug, as if the text is set from another function or event not associated with treeview it seems to automatically refresh the fields.

Regards

Ian
This topic is 8 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked