Set Grid width to sum of Column Widths 
Author Message
 Set Grid width to sum of Column Widths

I am trying to set the width and height of a flexGrid to fit the rows and
columns exactly. The code below comes close but still cuts out part of the
last col and last row. I am adding 10 to cover the grid lines, but I am
guessing at the value.

Is there a good technique to do this exactly?

Thanks

Public Function SetGridDim(g As MSFlexGrid)
  iTotal = 0
  For i = 0 To g.Rows - 1
    iTotal = iTotal + g.RowHeight(i) + 10
  Next i
  g.Height = iTotal

  iTotal = 0
  For i = 0 To g.Cols - 1
    iTotal = iTotal + g.ColWidth(i) + 10
  Next i
  g.width = iTotal

End Function



Tue, 10 Apr 2001 03:00:00 GMT  
 Set Grid width to sum of Column Widths



Quote:
>Is there a good technique to do this exactly?

No, that problem exists with some more controls. Perhaps you should set
ScaleMode to pixels, then you can add something around 3 pixels for every grid
line (1 for the line itself, and some more for a margin around it).

DoDi



Thu, 12 Apr 2001 02:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Setting datagrid column width sets width of toplevel!!

2. How to set column width in grids

3. Grid Control--How do I set column width?

4. ListView.Width <> Sum of ColumnHeader widths

5. ListView column width = ListView width ?

6. Total width of columns = Width of ListView

7. Total width of columns = Width of ListView

8. Make dbgrid columns width follow form width ???

9. Total width of columns = Width of ListView

10. Total width of columns = Width of ListView

11. Setting form width/height = image width/height

12. Setting Usercontrol (ocx) width at runtime wider than Width property of usercontrol

 

 
Powered by phpBB® Forum Software