cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Arthy_A26
Regular Visitor

Changing color of multiple sentences within context

Is there any way to Changing the color of multiple sentences within the same context. And the sentence starting and ending index are obtained from collections( api response are stored in collections)

Example context : Prime Minister Jacinda Ardern has claimed that New Zealand had won a big battle over the spread of coronavirus


Collection
String                   start   end
Jacinda Ardern.   16.     29
New Zealand.        48.     58
Coronavirus.          64.     74

 

Expected Output

 

Prime Minister Jacinda Ardern has claimed that New Zealand had won a big battle over the spread of coronavirus

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Arthy_A26 ,

 

Would you like to change font color of partial texts in a sentence?

 

If so, you will need to use the HtmlText box to display the sentence with tags. Since you have already set the strings that need to change color in a collection, you could use the Substitute function to replace all strings with tags in the whole sentence.

 

I made a test on my end:

119.png

 

So the steps are as follows:

1\ Add an HtmlText box, in this screen's OnVisible or a Button's OnSelect, set formulas as below:

ForAll(colColor,Patch(colText,First(colText),{Value:Substitute(First(colText).Value,ThisRecord.String,Concatenate("<font color=red>",ThisRecord.String,"</font>"))}))

 The colText collection is assuming that you have multiple sentences need to display. Above formula update the selected sentence by replacing strings in the collection with same string along with Html tags.

 

2\ Set HtmlText of HtmlText box to:

Last(colText).Value

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

 

View solution in original post

3 REPLIES 3
Arthy_A26
Regular Visitor

Is there any way to do it in powerapps?

Hi @Arthy_A26 ,

 

Would you like to change font color of partial texts in a sentence?

 

If so, you will need to use the HtmlText box to display the sentence with tags. Since you have already set the strings that need to change color in a collection, you could use the Substitute function to replace all strings with tags in the whole sentence.

 

I made a test on my end:

119.png

 

So the steps are as follows:

1\ Add an HtmlText box, in this screen's OnVisible or a Button's OnSelect, set formulas as below:

ForAll(colColor,Patch(colText,First(colText),{Value:Substitute(First(colText).Value,ThisRecord.String,Concatenate("<font color=red>",ThisRecord.String,"</font>"))}))

 The colText collection is assuming that you have multiple sentences need to display. Above formula update the selected sentence by replacing strings in the collection with same string along with Html tags.

 

2\ Set HtmlText of HtmlText box to:

Last(colText).Value

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

 

View solution in original post

Arthy_A26
Regular Visitor

Thank you so much @v-jefferni.. You helped me a lot

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

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

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