cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HendosMark
Frequent Visitor

Variables to update selected values in ListBox

Hi!

 

You guys have been great helping me in the past, and I hope that this continues today!!!

 

So I have a problem I need help with, relating to an Accident Reporting app I am building. Here is my scenario:

 

- I have an image on screen of a body outline

- I have added multiple Button Controls for each separate body part, i.e. Head, Neck, Shoulders, Chest, Stomach etc.

- I have set the buttons to fill red based on 2 triggers (example is for the head button):

 

1. Onselect = UpdateContext({pressedHead:!pressedHead})

2. Fill = if(pressedHead = true,Red,Transparent)

 

- I have a ListBox which is HIDDEN from the user, which I then want to update the selection to Match the body part pressed, but also allow for multiple selections - i.e. if I press the head and neck buttons, the list box selects Head and Neck from its list of options

 

Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
geneZebra
Resolver II
Resolver II

Typically this would be done by changing the defaults property of the list box to be the items you want selected but according to https://powerusers.microsoft.com/t5/General-Discussion/ListBox-control-Pre-select-the-multiple-value... it does not look like you can set more than 1 default item. 

 

Another suggestion is to use a gallery to mimic a listbox and use the controls in the gallery to control the fill. Somthing like label.fill= If(pressedHead, Red, rgba(0,0,0,0)

View solution in original post

3 REPLIES 3
geneZebra
Resolver II
Resolver II

Typically this would be done by changing the defaults property of the list box to be the items you want selected but according to https://powerusers.microsoft.com/t5/General-Discussion/ListBox-control-Pre-select-the-multiple-value... it does not look like you can set more than 1 default item. 

 

Another suggestion is to use a gallery to mimic a listbox and use the controls in the gallery to control the fill. Somthing like label.fill= If(pressedHead, Red, rgba(0,0,0,0)

View solution in original post

jhall
Continued Contributor
Continued Contributor

--edit--- Looks like @geneZebra had the same idea... 😄

I don't see how it gets done.  The ListBox control's default is a Text field and only allows one choice to be default.  As well, you can't change the SelectedItems value programmatically.

You can of course track this as a Collection and have a Collection of {Value:"Head",Selected:false}{Value:"Neck"...} and change those values as people click.  Then use that collection later for whatever you're needing.  It's specifically the ListBox control that looks like it can't do what you're wanting.

You could create something that "looks" like a listbox control out of a Gallery consisting entirely of Buttons and hiding their color/border and changing background color if your Collection's value of Selected (as I mention above) is True/False...

 

thanks @geneZebra and @jhall for your advice, as a workaround until I can invest more time in trying to get the gallery suggestion to work, i've pulled the variable text into a Text Label with ; separators, which can then be extracted using Excel for reporting purposes if needed.

 

Thanks for your swift responses!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (3,315)