Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21271

Programmatically set dimensions of MSFlexGrid based on columns/rows

$
0
0
I've found a few answers to this on the net but nothing is very accurate. Some leave scrollbars and others leave gray background area. I'm using VB6 and an MSFLexGrid control.

This is the basic code for setting up the grid

Code:

with grid

    .cols=3

    .ColWidth(0) = 400
    .Row = 0
   
    .Col = 1
    .ColWidth(1) = 800
           
    .Col = 2
    .ColWidth(2) = 0

end with

Code:

For X = 0 To .Cols - 1
      .Width = .Width + (.ColWidth(X) + Screen.TwipsPerPixelX))
 Next


 - and -


For X = 0 To .Rows - 1
      .Height = .Height + (.ColHeight(X) + Screen.TwipsPerPixelY))
 Next

That's the basic routine I'm using. It is not very accurate. For the width, for instance, it leaves horizontal scroll bars.

However, if I add the line

Code:

.Width = .Width + 23

- and -

.Height = .Height-140

to the end of the code, the scroll bar disappears.

Overall I'm using about 10 MSFlexGrids in my project and find the calculations differ on each table depending on the number of rows and columns each has. I have not adjusted the height of any rows so they remain at the default (240).

Oddly enough, when I step through the column calculations the .ColWidth(x) set at 400 comes out reading '405" and the one set to 800 reads '795" ... ???

Surely there must be a consistent way to accurately figure the dimensions?
TIA
Ken

Viewing all articles
Browse latest Browse all 21271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>