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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Row position in a grid. HELP ME!

Status
Not open for further replies.

serpico84

Programmer
May 18, 2011
13
IT
Hello everyone,
My problem is the cursor position within my grid work.
I try to explain the problem.
Mine is a dynamic grid, where the user can change values ??and enter data.
Whenever this happens, the cursor of the grid is re-calculated, erased, and hung up the grill with the new information.
My problem is when recalculating the cursor.
Let's take the example that I'm working on the 60 line, but my cursor on the screen would be the 20 grid line.
When the recalculation is no longer able to hang in the same position the cursor where I had left, and the only chance I have is:
nrec RECNO = ('cursor')

recalculation cursor

select cursor
go nrec

Effect of the grid ugly, puts the 20 grid line at the top of the grid giving the impression that everything above is deleted.

I do not know if I explained well, also because of the translation of google translate.

It would be really nice to hear your opinions about it and your experiences.

thank you very much
 
Effect of the grid ugly, puts the 20 grid line at the top of the grid giving the impression that everything above is deleted.

The solution to that is to call the grid's DoScroll method, passing 2 as the parameter. This will force the grid to scroll upward, so the user can see the rows above.

I'm not sure if I've understood the rest of your post, so if this doesn't answer your question, perhaps you could clarify it.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Thanks for Reply.
I think you know really well what I mean.
I also thought I doscroll to (), but ultimately this method will not redisplay the line on which you worked in the same position as before.
More or less will display the line in the center of the grid.
Obviously if I can not find anything more precise, I will use doscroll ()
 
Well you will need to record recno() and the current row position (visible row number) via grid.activerow. Then you can make use of goto record and doscroll to both reset the record position and the grid row position.

Bye, Olaf.
 
Keep in mind that you can use DoScroll() to scroll one line at a time, as well as a whole page. So you can store the record number before the value is re-calculated, then move the highlight back to that record after the recalculation, and then move the relevant row to where you want it.

If you want the highlighted row to be in the middle of the grid, you will have to know how many rows are visible. As far as I know, there's no property that tells you that, but, assuming the row height and the height of the grid are fixed, you should be able to easily work it out.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
I was thinking just that.
If I know:
1 - row height
2 - the height of the grid
3 - the distance between the selected row and the header.

I might be able to understand how many lines I have above my selected row.
I write down my information line, recalculating the cursor, and then with a goto I should be able to have what I need.

The first two pieces of information to know.
But the third!? As I can have it!?

Thanks guys.
 
Ok, throw in the towel. I can not find an accurate solution and that satisfies me.
I explained how the doscroll (). parameter 2
Why I can not understand how it works.
Sometimes I scroll through a line, sometimes I do see the line in the middle of the grid.
Thanks to all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top