Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why does a grid display search results in the middle?
Message
From
02/01/1998 12:44:20
 
 
To
02/01/1998 09:13:36
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00068309
Message ID:
00068953
Views:
56
>>>>I have a textbox and a grid on a form. The textbox is used to enter a search string. The grid displays the records from an ordered table (just as a browse would).
>>>>
>>>>However, the resultant matching record is always displayed in the middle of the grid. Why ?
>>>>In fpw, the browse window always showed your matching record at the very top of the window.
>>>>
>>>>Is there a way to get the grid to mimic the browse window ie: display the matching record(s) from the very top of the grid downwards, instead of from the centre of the grid downwards. ?
>>>>
>>>>Would be glad to get help on this, thanks.
>>>
>>>My first question would be are you using a filter for the grid data? If so... mmmm... It could be a long night. I always
>>>use a cursor or a view for grids... Just makes life a lot more livable.
>>
>>I am using an indexed table with no filter. The table was dragged onto the form from the Data Env. The textbox simply does a "seek" for the search-string in the table. The form is then refreshed. The row(record) that is found is always displayed in the middle of the grid.
>>The textbox keeps the focus (using a return 0, in the valid event) so that another search string can be entered.
>>
>>The grid is used to select desired records. If one was looking for names for eg. and the search-string entered was "Sam", the the first record containing "Samantha" is displayed in the middle row, followed by "Samuel", "Sera" etc. All the records(rows) above the middle row are wasted space (these could be the "R's). This grid is used to select desired records, and therefore I want the first matching record(s) to be displayed from the top of the grid, downwards.
>>
>>I believe the Doscroll command may work, but I have never used it before, and don't know how to call this method from within textbox, so that the textbox retains the focus.
>Hey I'm here at the moment and think you missed my reply. Here it's again changed for next search also.
>
>If you just want to mimic you could use doscroll method like this :

>
>* Textbox.lostfocus (Put this in textbox.lostfocus not in valid!)
>=seek(trim(this.value),tTable,cIndex)  && tTable table searched, cIndex Tag searched
>thisform.domimic = .t.
>thisform.grid1.setfocus() && Needed to fire afterrowcolchange<HR>
>*Grid.afterrowcolchange
>LPARAMETERS nColIndex
>if thisform.domimic
>	thisform.lockscreen = .t.
>	do while this.relativerow > 1     && Do while we are not on first row
>		this.doscroll(1)          && Scroll down
>	enddo
>	this.refresh
>	thisform.domimic = .f.            && So other movement in grid doesn't scroll
>	thisform.lockscreen = .f.
>	thisform.text1.setfocus()         && Again setfocus to search textbox
>endif	<HR>
>Cut and paste the code to appropriate places and changes names as needed.

Alright Cetin, here's a toughy for you.
Please don't waste any time on this, because it's really only cosmetic at the moment, NO BIG DEAL.

I'm in a grid column 1 row 4. I tab into column 2 row 4.
The GotFocus event of the control resets the table order (inGrid in case you're wondering).
Now I don't want the cursor to jump around the grid. IOW, since the cursor was on row 4 when I tabbed,
I want it to still be on row 4 in the new column, but still the same record.
I worked on this 1 1/2 years ago but never got it working quite right. I got something about 90% acceptable.

I repeat, this is more of a challenge that a request.

Bill
Bill Morris
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform