PUBLIC gcWords gcWords = "these are some words created to populate the checkbox controls" lo = CREATEOBJECT("myClass") lo.visible = .t. READ EVENTS DEFINE CLASS myClass AS Form Caption = "Checkbox Search Test" AutoCenter = .t. Width = 250 Height = 300 PROCEDURE Destroy CLEAR EVENTS thisForm.Release ENDPROC PROCEDURE Init LOCAL lnI, lcName, lo * Add checkboxes FOR lnI = 1 TO 10 lcName = "checkbox" + TRANSFORM(lnI - 1) thisForm.AddObject(lcName, "myCheckbox") lo = thisForm.&lcName lo.Left = 5 lo.Top = ((lnI + 1) * lo.Height) lo.Visible = .t. NEXT * Add search string thisForm.AddObject("Label", "Label") thisForm.Label.Caption = "Search:" thisForm.Label.AutoSize = .t. thisForm.Label.Visible = .t. thisForm.Label.Left = 5 thisForm.Label.Top = 7 * Add textbox thisForm.AddObject("txtSearch", "myTextbox") thisform.txtSearch.Top = 5 thisForm.txtSearch.Left = thisForm.Label.left + thisForm.Label.Width + 5 thisForm.txtSearch.Visible = .t. thisForm.txtSearch.SetFocus ENDPROC ENDDEFINE DEFINE CLASS myTextbox as TextBox PROCEDURE InteractiveChange LOCAL lnI FOR lnI = 1 TO thisForm.ControlCount IF PEMSTATUS(thisForm.Controls[lnI], "mth_highlight", 5) thisForm.Controls[lnI].mth_highlight(ALLTRIM(this.Value)) ENDIF NEXT ENDDEFINE DEFINE CLASS myLabel AS Label BorderStyle = 0 BorderWidth = 0 ENDDEFINE DEFINE CLASS myCheckbox AS Container lo = .NULL. loLbl = .NULL. loLbl1 = .NULL. loLbl2 = .NULL. loLbl3 = .NULL. BorderStyle = 0 BorderWidth = 0 Width = 300 Height = 20 PROCEDURE Init LOCAL lcCheckBox, lcLabel, lcLabel2, lcLabel3 lcCheckbox = SYS(2015) lcLabel = SYS(2015) lcLabel1 = SYS(2015) lcLabel2 = SYS(2015) lcLabel3 = SYS(2015) * Checkbox this.AddObject(lcCheckbox, "CheckBox") this.lo = this.&lcCheckBox this.lo.Caption = SPACE(0) this.lo.AutoSize = .t. this.lo.Visible = .t. * Label for display this.AddObject(lcLabel, "Label") this.loLbl = this.&lcLabel this.loLbl.Caption = GETWORDNUM(gcWords, 1 + INT(VAL(RIGHT(this.Name, 1)))) this.loLbl.AutoSize = .t. this.loLbl.Left = this.lo.left + this.lo.width + 5 this.loLbl.Visible = .t. * For highlighting labels this.AddObject(lcLabel1, "Label") this.AddObject(lcLabel2, "Label") this.AddObject(lcLabel3, "Label") this.loLbl1 = this.&lcLabel1 this.loLbl2 = this.&lcLabel2 this.loLbl3 = this.&lcLabel3 this.loLbl2.BackColor = RGB(0,255,0) this.loLbl2.ForeColor = RGB(0, 0, 0) ENDPROC PROCEDURE mth_highlight LPARAMETERS tcText LOCAL lnAt lnAt = AT(LOWER(tcText), LOWER(this.loLbl.Caption)) IF NOT EMPTY(tcText) AND lnAt > 0 * It was found * Turn off the solid display label this.loLbl.visible = .f. * Display the other labels IF lnAt = 1 * It's at the beginning, only lbl2 and lbl3 this.loLbl2.Caption = LEFT(this.loLbl.Caption, LEN(tcText)) this.loLbl2.Left = this.loLbl.Left this.loLbl2.AutoSize = .t. this.loLbl2.Visible = .t. ELSE * It's somewhere in the middle, lbl1, lbl2, and lbl3 * Leading portion this.loLbl1.Caption = LEFT(this.loLbl.Caption, lnAt - 1) this.loLbl1.Left = this.loLbl.Left this.loLbl1.Visible = .t. this.loLbl1.AutoSize = .t. * Highlight portion this.loLbl2.Caption = SUBSTR(this.loLbl.Caption, lnAt, LEN(tcText)) this.loLbl2.Left = this.loLbl1.Left + this.loLbl1.Width - 2 this.loLbl2.Visible = .t. this.loLbl2.AutoSize = .t. ENDIF * Do we need a trailing portion? IF lnAt + LEN(tcText) <= LEN(this.loLbl.Caption) * Yes this.loLbl3.Caption = SUBSTR(this.loLbl.Caption, lnAt + LEN(tcText)) this.loLbl3.Left = this.loLbl2.Left + this.loLbl2.Width - 2 this.loLbl3.Visible = .t. this.loLbl3.AutoSize = .t. ELSE * Nope this.loLbl3.Visible = .f. ENDIF ELSE this.mth_unhighlight ENDIF ENDPROC PROCEDURE mth_unhighlight this.loLbl.visible = .t. this.loLbl1.visible = .f. this.loLbl2.visible = .f. this.loLbl3.visible = .f. ENDPROC ENDDEFINE