Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Record pointer in a grid

Status
Not open for further replies.

David Higgs

Programmer
May 6, 2012
390
0
16
GB
In my transition from using "Browse" to using a "Grid" I have the following question:-

When I call "myform" using two command buttons ("Top" and "Bottom") to display "mygrid" I would like to set the "Record Pointer" to "Top" or "Bottom" how do I go about this?

Regards,
David
 
select YourTableName
Locate && or GO BOTT
thisform.YourGridName.Refresh()


Ez Logic
Michigan
 
Many thanks, I think I was confusing myself! I had two command buttons on my_main_menu calling myform which contains mygrid. I've now placed the two buttons on myform containing the grid and added your code.

Regards,
David
 
David,

The thing to remember about grids is that the navigation is performed on the underlying table, not on the grid itself. Whenever you move the record pointer in the table, the highlight in the grid will automatically be moved as well, to keep it in sync.

After moving the record pointer, it's usually necessary to set focus to the grid, in order for the grid to reflect the new position of the highlight. Just do THISFORM.MyGrid.SetFocus. You can alternatively do a refresh, as EZ suggested, but SetFocus is usually faster.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Many thanks Mike.

Although I can see many advantages in using a Grid vs Browse, there is a lot to learn!



Regards,
David
 
I would use setfocus after the refresh.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Makes me wonder how you go about that in browse. You do GO TOP or GO BOTTOM before BROWSE, don't you? Isn't it the same?
A Browse is a grid, which you can see by doing BROWSE NAME xyz and then do [tt]? xyz.Class[/tt]

So the NAME clause of browse gives you a reference to the grid of the browse window.

You can learn everything that is set in xyz by eg doing xyz.SaveAsClass("D:\mycode\mylibrary.vcx","browseofsomedbf")
Then modif that class and look into the grid, columns and textbox controls to see how controlsources etc are set.

Bye, Olaf.
 
My thought was that refresh() perhaps wasn't enough, and setfocus() is helpful... but now I think about it, a Refresh() will
fire the afterrowcolumnchange() event most likely - so if you have related grids, textfields etc, they can be updated too.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
It's a shame there is no VFP10 so the grid can be further updated. It is better than any other language' native grid tool that
I know of, very consistent, not like that mess of a datagridview in c# - which promises so much when you do simple things
in 'automatic' mode, but makes every table a novel of code with anything tricky (i.e. including combinations of check boxes
text images and drop downs - the kinds of things that VFP's grid handles so well from the IDE).

Only snag is, the VFP grid is getting a bit scraggly in the new environments - screen updates and stuff are starting to look a bit rough.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Sorr, Griff, my question about BROWSE was addressing DPGH saying "there is a lot to learn", while actually navigating to e record is the same with BROWSE and GRID.

There of course is a lot to learn about the grid, as it's a complex control with many properties/settings and sub structure columns and controls. But browse is a grid, so all browse features are available in the grid. Using the SaveAsClass method you can load the class in the class designer, open property winodow and set it up to ony show non default values and you'll see what grid, column or control properties are set in what way to get a grid set up as the BROWSE command clauses do it.

Bye, Olaf.
 
Don't worry about crossed wires Olaf, we can sort the chaff from the wheat

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top