Hello everyone,
I'm writing to you because I'm stuck on a manipulation that I think is actually simple to perform.
I created a list on sharepoint that I put on powerapps as Forms. In this list is a drop-down menu in which I have the values "TB", "B", "M", "I", "TI" (which means very good, good, average, insufficient, really insufficient, in French).
My goal is to display these values with different colors in the dropdown menu ("TB" in green for example and "TI" in red).
I already managed to display the final value with its color in SelectedTagFill with this code (you can find the result in attachment Screenshot 1):
If(
DataCardValue25.Selected.Value = "TB", Color.MediumSeaGreen,
DataCardValue25.Selected.Value = "B", Color.DarkTurquoise,
DataCardValue25.Selected.Value = "M", Color.Gray,
DataCardValue25.Selected.Value = "I", Color.Gold,
DataCardValue25.Selected.Value = "TI", Color.Tomato
)
The color is also correct in the SelectionFill (screenshot 2).
But all the boxes are white and I can't assign the right color to them, I would like each choice to have a different color when I unroll the menu.
I have the same problem with my HoverFill (I put the same code than for my SelectedTagFill) which when I move my mouse over the values has the color of the selected value and not a different color each time (Screenshot 3).
I tried with "DataCardValue25.Value" instead of "DataCardValue25.Selected.Value" but I have an error.
Please to you have a tips for me ?
(I tried to make
If(
DataCardValue25.Selected.Value = "TB", Color.MediumSeaGreen,If(
DataCardValue25.Selected.Value = "B", Color.DarkTurquoise, If(
DataCardValue25.Selected.Value = "M", Color.Gray, If(
DataCardValue25.Selected.Value = "I", Color.Gold, If(
DataCardValue25.Selected.Value = "TI", Color.Tomato
)))))
But I have the same result).
Solved! Go to Solution.
Hi @Marie_Causse ,
Yes that is correct - there is no way of having different colours in each item of a drop-down.
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Hi @Marie_Causse ,
Use this
Switch(
Self.Selected.Value,
"TB", Color.MediumSeaGreen,
"B", Color.DarkTurquoise,
"M", Color.Gray,
"I", Color.Gold,
"TI", Color.Tomato
)
on the SelectionFill and then the Color is simply
Self.SelectionFill
Your HoverFill will be dependant on what is selected (it does not know what it is hovering over), but you can use the same syntax on it.
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Thank you, your way to write it is so much cleaner et easier, I am going to use it ! But this does not change the result...
I always have the color that corresponds to the color of the selected text and not a different color or one that changes depending on the text.
Looks like it doesn't change the color when the selection is changed. The solution could be:
DataCardValue25.HoverFill = selectedTextColor
DataCardValue25.OnChange =
Switch(
Self.Selected.Value,
"TB",
UpdateContext({selectedTextColor: Red}),
"B",
UpdateContext({selectedTextColor: Blue})
)
Hi @Marie_Causse ,
Yes that is correct - there is no way of having different colours in each item of a drop-down.
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Ok, thank you for your help. Have a good day !
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
184 | |
53 | |
50 | |
36 | |
35 |
User | Count |
---|---|
271 | |
91 | |
82 | |
76 | |
75 |