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

Grid columns and rows

Status
Not open for further replies.

sdocker

IS-IT--Management
Aug 12, 2010
218
GB
Why does a grid have an extra blank column? I set the ColumnCount to 2 and there are three columns, although the third column is not accessable.

At run time there are extra rows at the bottom, also not accessible.

I can hide the extra column by adjusting the width, but I can't seem to avoid the extra rows.

Thank you.
Sam
 
It might look like an extra column, but in fact it's not a column at all. It's just the space left over at the right-hand side of the grid.

Put another way, if the grid is 100 pixels wide, and it contains two columns of data, each 40 pixels wide, the so-called "third column" is the unused 20 pixels.

If you don't want it to show, you can adjust the widths of the columns so that they exactly add up to the width of the grid. Unfortunately, it's a little more complicated than that, because you also need to take account of the grid border, vertical scroll bar, and even the lines between the columns. But you can usually get it right with a bit of trial and error.

As for the extra rows, those are harder to explain. Basically, they represent the empty space at the bottom of the grid, just as the column represents the empty space at its right. The only reason they are necessary is that it's possible to scroll the grid so that the bottom row of data appears at the top of the visible grid, and you therefore need something underneath that.

But that's not really a good explanation. There's no real reason to allow the grid to be scrolled in that way. It would be just as valid to make it so that the last real row is never above the last physical row, in which case the empty space wouldn't be necessary. Many third-party grid controls work that way.

It might be possible to avoid the empty rows by writing code in the Scrolled event such that, whenever the user scrolls the grid in such a way as to reveal the empty rows, the grid would automatically scroll itself so that the last row is at the bottom. But I suspect that would look ridiculous, and would confuse the users no end.

Personally, I would just leave things as they are, and live with it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
The 'extra' columns...

Could it be that the 'extra' column is actually the Delete Mark 'column' that you are seeing?

Otherwise if you set the column count to n you will get n columns showing in the grid.

Alternatively if you should happen to Size the Grid bigger than the Column needs, you will see a blank 'column' with no header, etc. on the far right due to the over-size Grid frame.

At run time there are extra rows at the bottom, also not accessible.

And yes, the over-size Grid Frame will show additional 'rows' if your Grid is over-sized in that direction as well. But those 'additional rows' are not really data source records.

These 'extra rows' are part of the Grid Display due to how you sized it within the Form, not 'real data rows'

Good Luck,
JRB-Bldr



 
Thanks. My questions have been answered.
 
Are using the grid to display stored data or to add data, if for displaying stored data make sure that the grid's Allow add new property is False and column count = 2 and
lock columns = 0 and lock columns left = 0 and partition = 0 and record source type = Alias.
I hope this works for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top