Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Highlight record on grid as table index moves
Message
From
28/05/2004 06:45:15
Dorin Vasilescu
ALL Trans Romania
Arad, Romania
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00908074
Message ID:
00908076
Views:
27
Hi
Something like this ?

I've posted a new class, is new and buggy yet, but it does something like this and much more
Try it and tell me what you think about it
CREATE table test (id I , desc c(20))
INSERT INTO test (id,desc) VALUES (12345 , 'Row desc 12345')
INSERT INTO test (id,desc) VALUES (56788 , 'Row desc 56788')
INSERT INTO test (id,desc) VALUES (14455 , 'Row desc 14455')
INSERT INTO test (id,desc) VALUES (15566 , 'Row desc 15566')
INSERT INTO test (id,desc) VALUES (42211 , 'Row desc 42211')
GO TOP 

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




PROCEDURE grid_highlight_prep
parameters  toGridRef,tnSelForeColor,tnSelBackColor,tcPreservedColumns
local lnForeColor,lnBackColor,i
toGridRef.addproperty('GridRecno',0)
lnForeColor = toGridRef.ForeColor
lnBackColor = toGridRef.BackColor
tcPreservedColumns = IIF(VARTYPE(tcPreservedColumns)#'C','',tcPreservedColumns)
FOR i=1 TO toGridRef.ColumnCount
	IF !toGridRef.Columns(i).name $ tcPreservedColumns
		toGridRef.Columns(i).DynamicBackColor = ;
			"iif(this.GridRecno = RECNO(),"+alltrim(str(tnSelBackColor))+","+alltrim(str(lnBackColor))+")"
		toGridRef.Columns(i).DynamicForeColor = ;
			"iif(this.GridRecno = RECNO(),"+alltrim(str(tnSelforeColor))+","+alltrim(str(lnForeColor))+")"
	ENDIF
ENDFOR
RETURN

*-----------------------
procedure grid_highlight
parameters toGridRef
if recno()# toGridRef.GridRecno 
	toGridRef.GridRecno =  recno()
	toGridRef.visible = .t.
endif





DEFINE CLASS form1 AS form

	Top = 7
	Left = 2
	Height = 326
	Width = 412
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"


	ADD OBJECT text1 AS textbox WITH ;
		Alignment = 3, ;
		Value = 0, ;
		Height = 23, ;
		Left = 72, ;
		Top = 36, ;
		Width = 120, ;
		Name = "Text1"


	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 36, ;
		Left = 204, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Search ", ;
		Name = "Command1"
 
 	ADD OBJECT grid1 AS grid WITH ;
		ColumnCount = 2, ;
		Height = 193, ;
		Left = 36, ;
		Panel = 1, ;
		RecordSource = "test", ;
		Top = 108, ;
		Width = 337, ;
		Name = "Grid1", ;
		Column1.ControlSource = "test.id", ;
		Column1.Width = 75, ;
		Column1.Name = "Column1", ;
		Column2.ControlSource = "test.desc", ;
		Column2.Width = 175, ;
		Column2.Name = "Column2"





	PROCEDURE grid1.AfterRowColChange
		LPARAMETERS nColIndex
		grid_highlight(this)
	ENDPROC


	PROCEDURE grid1.Init
		grid_highlight_prep(this , this.column1.text1.SelectedForeColor , this.column1.text1.SelectedBackColor  , '')
	ENDPROC


	PROCEDURE command1.Click
		nRecNo = RECNO('test')
		LOCATE FOR id = thisform.text1.value
		IF FOUND()
			thisform.grid1.GridRecno = RECNO()
			thisform.grid1.refresh()
		ELSE 
			GOTO nRecno
		ENDIF 
	ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
>Hi,
>
>Does anybody has done this?
>
>What I'm trying to do is like this..

>
>I have a form that have this controls,

>1. Grid
>2. Optionbutton
>3. Search Box

>
>As I search a record from a table bound to the Grid as its Recordsource, I want the record in the grid highlighted,

>
>If I have records like the ff:
>123456 => Record 1
>123557 => Record 2
>123458 => Record 3
>225645 => Record 4
>

>Highlighted is record 1
>Lets say i want to search record 2 into my search box, it should be highlighted as the record pointer moves into that particular record, as I type 123557 for the next record the pointer moves and it must be highlighted also.
>
>Please share your code or tell me how can I do this...
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform