Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stay highlighted after move down
Message
From
25/08/2001 05:16:47
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
24/08/2001 17:07:05
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00548998
Message ID:
00549115
Views:
18
>Hi,
>
>I have a grid who's recordsource is a sql statement. Anyways, I have 'move up' and 'move down' buttons on the form. I've got that working. After some troubles I was able to get the grid to refresh. Here's how
>
>with thisform.grdQuestions
>	.recordsource="select question, rank, tkey, qkey from qtable " + ;
>                "into cursor questions order by rank" + ;
>		" where tkey = '" + lcTkey + "'"
>	.refresh()
>	.setfocus()	
>endwith
>
>
>Here's the problem I don't know how to solve. After the grid is refreshed I would like the record that was moved to be still highlighed, instead of the first record being highlighted. For example,
>
>grid contents before move down
>"Hello"
>"How Are you"
>"I am fine"
>
>grid contents after move down
>"How Are You"
>"Hello"
>"I am fine"
>
>Any ideas? I tried making a index on the cursor and seeking the correct record after the refresh, but that caused problems.
>
>Chris

Chris,
As far as I understand you're trying to mimic moverbars in a grid with keyboard. Considering a 'question' table is generally very light I didn't think of a more effective technique :
*Form.init
create cursor questions (Rank i,Question c(30))
insert into questions values (1,'Hello')
insert into questions values (2,'How are you')
insert into questions values (3,"I'm fine and you?")
insert into questions values (4,"Not bad.")
index on rank tag rank
* For your case this could be a RW cursor selected from qtable

*Form.Keypress && Keypreview .t., no check if we're in grid!!!
LPARAMETERS nKeyCode, nShiftAltCtrl
if nKeyCode = 24 and rank < reccount() && down
 nodefault
 this.Swap(rank,1)
endif
if nKeyCode = 5 and rank > 1 && up
 nodefault
 this.Swap(rank,-1)
endif

* Form custom swap method
lparameters tnPos, tnRelative
with this
	copy to array arrTemp
	arrTemp[tnPos,1] = tnPos+tnRelative
	arrTemp[tnPos+tnRelative,1]=tnPos
	with .Grid1
		lnCol = .Activecolumn
		.Recordsource=''
		zap
		append from array arrTemp
		.Recordsource='Questions'
		go tnPos
		.refresh
		.Columns(lnCol).setfocus()
	endwith
endwith
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform