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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
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
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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