Fit-to-width columns in MSHFlexGrid 
Author Message
 Fit-to-width columns in MSHFlexGrid

I want to resize the last column of the MSHFlexGrid so that its width
is maximized to the point where all the viewable grid space is
occupied yet there isn't a horizontal scrollbar.

I came up with the formula:
m_lTwipsPerPixelX = Screen.TwipsPerPixelX
lScrollbarWidth = GetSystemMetrics(SM_CXVSCROLL) * m_lTwipsPerPixelX
lNewWidth = Grid.Width - Grid.ColPos(lCol) - lScrollbarWidth

This seems to come up a little short, though. I narrowed the problem
down to the extra pixels taken-up by the grids border. This border is
variable, depending on properties Appearance, BorderStyle, and maybe
some others.

Could someone please help me come up with a better formula.

Thank you,
Chad



Wed, 09 Mar 2005 09:12:36 GMT  
 Fit-to-width columns in MSHFlexGrid
Use the GetClientRect API. This will return the actual inside dimensions of
your grid. It takes the scrollbar and borders into account.

Rocky


Quote:
> I want to resize the last column of the MSHFlexGrid so that its width
> is maximized to the point where all the viewable grid space is
> occupied yet there isn't a horizontal scrollbar.

> I came up with the formula:
> m_lTwipsPerPixelX = Screen.TwipsPerPixelX
> lScrollbarWidth = GetSystemMetrics(SM_CXVSCROLL) * m_lTwipsPerPixelX
> lNewWidth = Grid.Width - Grid.ColPos(lCol) - lScrollbarWidth

> This seems to come up a little short, though. I narrowed the problem
> down to the extra pixels taken-up by the grids border. This border is
> variable, depending on properties Appearance, BorderStyle, and maybe
> some others.

> Could someone please help me come up with a better formula.

> Thank you,
> Chad



Sat, 12 Mar 2005 01:46:54 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. DataGrid Setting Width of Columns to Fit Autofit.

2. MSHFlexgrid Column Widths

3. how to know the MSHFLEXGrid column width

4. Maximum width of MSHFlexGrid line (column)

5. Column width in MSHFlexgrid control

6. MSHFlexgrid hierarchical indents and column widths

7. MSHFlexGrid Column Width

8. MSHFlexGrid column widths

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

10. Set Grid width to sum of Column Widths

11. ListView column width = ListView width ?

12. Total width of columns = Width of ListView

 

 
Powered by phpBB® Forum Software