Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

is it possible for change property of partial content?

Let's say I have a text field with "I like red color", is possible just highlight the word "red' in red color instead of making the whole text in red color?


  • Yes. The SELECTION property I mentioned before will do that if you use the correct starting position and length.
  • I missed the part about "red color". The SELECTION property will use the default system color.
  • @DonBakke
    I had tried SELECTION before but it didn't work,
    after setting the whole text then I used:
    set_property(ctrlID, "8:@fm:3 ", "SELECTION")
    set_property(ctrlID, "RED", "FORECOLOR")

    it still set the whole sentence in red color

  • Hopefully the content of the text field will allow you to be a little creative.
    Are you aware of what is actually going to be the text as in are there a limited number of possibilities?
    If so, are they all similar in content?

    If you are aiming for something like
    I like red colour
    I like blue colour
    I like yellow colour
    where just the one word is changing colour, use three separate text fields.
    One text field will always display "I like", then a separate text field in the middle for the actual coloured word and then a third text field with the word "colour".
    So you only need change the forecolor of the middle text field
  • @AusMarkB
    I can't do that because there are two many combinations, I just gave the example to simplify my question, in reality , I have to create more than 50 different text fields if I do it in that way, thats why I want to change partial content
  • @slowjams - Your original post was confusing because highlighting normally means selecting in OI, thus I missed the requirement to color code the highlight. I'm now a bit more confused because you referenced the FORECOLOR property, which doesn't highlight at all but only changes the color of the text.

    There really isn't a way to do what you want. You can highlight (via the SELECTION property) or you can make specific text a certain color by using an RTF textbox and formatting the content appropriately.
  • Then I think you're out of luck. I don't think there's any control that allows for mixed font/colour for the purpose you describe.
  • well except for an RTF textbox :P
Sign In or Register to comment.