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

Grid not filling up window completely... 3

Status
Not open for further replies.

Mandy_crw

Programmer
Jul 23, 2020
578
PH
Hi everyone... i dont know if i can consider this as a problem... but my grid is not filling up the window, only 8 items is shown, after that if i add another item, it shows the scroll bar already eventhough i still have 4 blank rows... May i ask for a solution please... thanks....
 
To fit grid on your form use its anchor property.
To hide scrollbars set ScrollBars property of grid to 0.
 
If you set Scrollbars to 0 (none) the scrollbar don't show.

Otherwise the scrollbar region is there even with 0 records, to illustrate:
emptygrid_xmet6k.jpg

What appears after I add two records is the slider of the scrollbar, but the scrollba is already there from the beginning.

slidergrid_p2i0el.jpg

The slider is the darker gray rectange inside the scrollbar region, here shown in a grid with 2 records. The slider initially is full height. Is that what you mean?

The slider, which is sized as the portion of records you see in comparison to all records, will shrink when you add many more items and the visual portion is shrinking, but it's naturlly full height if you see all records. The question is rather, why it's only appearing when you have 2 or more records (at least that's what I experience), it's kind of logic it's missing with no records, but should be there when the first record exists.

The whole scrollbar is there from the start, though, it doesn't appear, it's already there. I wonder what you describe is the appearance of the slider of the scrollbar.

The simplest way to get rid of that, as initially said, is to set ScrollBars=0 and get rid of them overall. You have no influence on when VFP thinks the scrollbar slider should appear. You could also think about initially having no scrollbars and set Scrollbars to 2 (vertical) when you reach a reccount() that's one more than can fit into the grid height divided by rowheight (take into account the headers, too). Then you actually have both the scrollbar and its slider appear only when needed to scroll, in the moment you added the item that breaks the display limit.

Or you still keep the scrolllbars off, the scrollbar is not the only option to scroll down. There's mouse wheel scrolling and arrow keys. And, of course, you can simply add own buttons for up and down scrolling, perhaps even better suited for touch usage, as the scrollbar is very slim, so it can be "finger friendlier" with dedicated navigation buttons, can't it? And you don't need to fiddle with that problem.

Chriss
 
Mandy,

Are you saying that when you scroll down to the bottom of the grid, you are seeing a number of blank rows, that is, rows situated between the last actual row and the bottom of the grid? And that you don't want those blank rows to be visible? In other words, in those circumstances you want the last actual row of data always to be on the last row of the visible grid?

Have I understood your question correctly? If so, I can only say that you have hit on one of more annoying features of the VFP grid - and one for which (as far as I know) there is no easy solution.

However, if you happen to own a copy of 1001 Things You Wanted to Know About Visual Foxpro, you will find a very effective solution on pages 173 - 175. Unfortunately, the code is much too long for me to type here (even if I was allowed to). You might possibly find a copy on line somewhere, or it might be worth your while to buy the book.

Apologies if I have misunderstood the question.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Ravindra, Chris and Mike... OMG... it worked... putting the scrollbars to 0. Thanks and God bless everyone....
 
It's obviously the simplest solution, if you don't want or need them anyway. I wonder why you described what seems inconvenient to you about when the scrollbar (or slider) appears, as it seemed unlogical to you. But it also sounded like you wanted to control that appearance, not get rid of the scrollbar overall. That's much simpler, then.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top