Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Change color of a substring of a caption
Message
From
04/03/2019 15:57:54
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01666960
Message ID:
01666968
Views:
61
>>>Hi,
>>>
>>>I have a window/form that has many check boxes. Each check box has a caption. I want to add a text box at the top of the form so that the user can search for any check box caption which contains the entered text. For example, when a user enters "fox", a method of the form will scan all check boxes and check if the caption has the word "fox." So far, it is all fairly easy to do.
>>>
>>>But then I want the substring of the caption to change the color (or make it bold). For example, if a check box has a caption
>>>"Visual FoxPro" I want the word/substring "Fox" to be highlighted by a color or make it bold.
>>>
>>>Is this possible? And if yes, how? TIA
>>
>>Another option is simply to change the back color. I use that quite often for those kinds of searches. Add them to an array of objects to reset to the prior color when the search is cleared, or add a "mth_reset()" method to your class which resets it to what it looked like at the end of the Init() event, or any subsequent property change.
>
>Yes, changing the back color or setting the caption to have fontbold .T. will make it stand out. I was just trying to be more "fancy" and change the back color of just the substring of the caption.

To find out where to position it, use two labels. One that is not visible, but is set to auto-size. It will contain the left-most text, and you can get the width from it to know where to overlay the other one.

If text searched for is "there" and you have a checkbox with "Hi There!" you'll have to recognize the upper-case width there in the search string, so be sure to determine the location in the string using lower() or upper() and get the starting offset, but then actually sample the real string to extract to determine the real width.

Will be a nice control. Martina's a genius. :-)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform