Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Change color of a substring of a caption
Message
From
05/03/2019 16:08:27
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01666960
Message ID:
01667002
Views:
78
>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

I think we may all be over-thinking this.
Just use several autosize labels and move them so they appear to be one label.

I made an example form:
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


DEFINE CLASS form1 AS form


	Top = 0
	Left = 0
	Height = 113
	Width = 290
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"


	ADD OBJECT text1 AS textbox WITH ;
		Height = 24, ;
		Left = 12, ;
		Top = 36, ;
		Width = 145, ;
		Name = "Text1"


	ADD OBJECT label1 AS label WITH ;
		AutoSize = .T., ;
		Caption = "Fox", ;
		Height = 17, ;
		Left = 24, ;
		Top = 12, ;
		Width = 21, ;
		Name = "Label1"


	ADD OBJECT label2 AS label WITH ;
		AutoSize = .T., ;
		Caption = "Pro", ;
		Height = 17, ;
		Left = 46, ;
		Top = 12, ;
		Width = 21, ;
		ForeColor = RGB(255,0,0), ;
		Name = "Label2"


	PROCEDURE text1.InteractiveChange
		THisForm.label1.Caption = ALLTRIM(This.value)
		ThisForm.label2.Left = THisForm.label1.Left+THisForm.label1.Width
	ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform