Powershell Studio 2014 - ListView and Radio Button question

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

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 9 years and 1 month 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.
User avatar
PBilat
Posts: 7
Last visit: Tue Dec 19, 2017 1:09 am

Powershell Studio 2014 - ListView and Radio Button question

Post by PBilat »

I have made in Powershell Studio 2014 a ListView with 7 items (2 items are selected by Default)

Now I have a radio button (Name: Select all). How can I configure this radio button to select all items in the ListView?

Variable names:
Radio button: rbSelectAllExtensions
ListView: lstWordExtensions


Thank You in advance for help....

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

Powershell Studio 2014 - ListView and Radio Button question

Post by SAPIEN Support Forums »

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

Thank you for posting, postmaster@bilat.ch.

Did you remember to include the following?
  • 1. Product, version and build (e.g. Product: PowerShell Studio 2014, Version & Build: 4.1.71. Version and build information can be found in the product's About box accessed by clicking the blue icon with the 'i' in the upper right hand corner of the ribbon.)
    2. Specify if you are running a 32 or 64 bit version
    3. Specify your operating system and if it is 32 or 64 bit.
    4. Attach a screenshot if your issue can be seen on the screen
    5. Attach a zip file if you have multiple files (crash reports, log entries, etc.) related to your issue.
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
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Powershell Studio 2014 - ListView and Radio Button quest

Post by Alexander Riedel »

You do not use a radio button for this type of activity. Radio buttons are used to select one of multiple, mutually exclusive items.

For a "Select all" functionality you would usually use a simple push button.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
PBilat
Posts: 7
Last visit: Tue Dec 19, 2017 1:09 am

Re: Powershell Studio 2014 - ListView and Radio Button quest

Post by PBilat »

Hello Alexander,

Thank You for your answer. A simple push button. OK, I will give it a try.

But what about the code for this push button? Do You have an example for selecting all items over a push button=


Pascal Bilat
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Powershell Studio 2014 - ListView and Radio Button quest

Post by davidc »

To select all the items, you have to set the Select property to $true for each item:
PowerShell Code
Double-click the code block to select all.
foreach ($item in $listview1.Items)
{
     $item.Selected = $true			
}
I recommend reading the spotlight article on the ListView:

http://www.sapien.com/blog/2012/04/04/s ... ol-part-1/

David
David
SAPIEN Technologies, Inc.
User avatar
PBilat
Posts: 7
Last visit: Tue Dec 19, 2017 1:09 am

Re: Powershell Studio 2014 - ListView and Radio Button quest

Post by PBilat »

Hello David,

Thank You for your Suggestion. I have created a button "Select all" and tried the following code..


$btnSelectAll_Click={
#TODO: Place custom script here
foreach ($item in $lstWordExtensions.Items)
{
$item.Selected = $true
}
}

but it's not running?! And Yes, I have read and downloaded all Spotlight article and other stuffs/examples from Sapien.

Pascal
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Powershell Studio 2014 - ListView and Radio Button quest

Post by davidc »

Are you getting an error message?

Also make sure you have the ListView's MultiSelect property set to True.

David
David
SAPIEN Technologies, Inc.
User avatar
PBilat
Posts: 7
Last visit: Tue Dec 19, 2017 1:09 am

Re: Powershell Studio 2014 - ListView and Radio Button quest

Post by PBilat »

Hi davidc,

I have found the Problem with my code. Now it's running. I had to Change the code from item.Selected to item. I have changed the Radio button to a simple button as You explain me.

Example:
$btnSelectAllDocTypes_Click= {
# Click will select all items on Word Extensions Types to scan in ListView

foreach ($item in $lstWordExtensions.Items)
{
$item.Checked = $true
}
}

$btnUnselectDocTypes_Click={
# Click will unselect all items on Word Extensions Types to scan in ListView
foreach ($item in $lstWordExtensions.Items)
{
$item.Checked = $false
}
}

$btnSelectAllDocProps_Click={
# Click will select all items on Microsoft Word Document Properties in ListView
foreach ($item in $lstWordProperties.Items)
{
$item.Checked = $true
}
}

$btnUnselectDocProps_Click={
# Click will unselect all items on Microsoft Word Document Properties in ListView
foreach ($item in $lstWordProperties.Items)
{
$item.Checked = $false
}
}


That's great. Thank You very much

Pascal Bilat
Attachments
Printscreen button Select all
Printscreen button Select all
Button-Select all clicked.jpg (260.13 KiB) Viewed 3828 times
This topic is 9 years and 1 month 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.