cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
guyinkalamazoo
Helper III
Helper III

List box unselect

I have a few different listbox controls whose items are from a SharePoint list.  Each item has a numerical score associated with it.  When the end user selects an item, it is easy to set a global variable to that accumulated value (for each selected).  But if they unselect an item is there a simple way to subtract that score from the cumulated value.  I did not see an unselect function for a listbox. How might I be able to do this?  Thanks for the advice

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@guyinkalamazoo 

You really don't need to do any variable setting for the control.  It already has the list of items selected that you want.

If you refer to the SelectedItems of the list box, it will contain anything selected.  It will always reflect what is selected in the list.

Setting a variable for this would be very "program-like" and PowerApps is not a development platform.  So consider just referencing the control in your app.

 

Ex.  Listbox1 on the screen with the appropriate Items property.

To see the selected...(as an example) put another list box on the screen and set the Items property to Listbox1.SelectedItems

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

5 REPLIES 5
RandyHayes
Super User
Super User

@guyinkalamazoo 

You really don't need to do any variable setting for the control.  It already has the list of items selected that you want.

If you refer to the SelectedItems of the list box, it will contain anything selected.  It will always reflect what is selected in the list.

Setting a variable for this would be very "program-like" and PowerApps is not a development platform.  So consider just referencing the control in your app.

 

Ex.  Listbox1 on the screen with the appropriate Items property.

To see the selected...(as an example) put another list box on the screen and set the Items property to Listbox1.SelectedItems

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Yes, this is very helpful and I am hoping I can wrap a Sum() around the lb.SelectedItems.  That would be perfect.  Thanks for the information

RandyHayes
Super User
Super User

@guyinkalamazoo 

Yes, you can...

ex.  Sum(lb.SelectedItems, someValue)

 

Just keep one thing in mind about list boxes - you CANNOT automatically select items in the list.  This is a long running issue about Listboxes and very annoying if you want to use one to display some values that are in some datasource.

Not sure if that is a factor for you going forward, but wanted to point it out.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thanks again.  This will work for me as I do not need anything preselected.  I just subbed to your channel too 🙂

RandyHayes
Super User
Super User

@guyinkalamazoo 

Good deal...then the Listbox will do the trick.

And thanks for subbing to the channel!!  I am really behind on posting videos, but have it on my schedule before year end.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,479)