There isn't currently a method which you can use to ensure that the grid is autosized to display a certain row (or number of rows) regardless of whether the bottom scroll bar is displayed or not. Possible options (other than leaving room for the scroll bar) are:
1) Prevent the user from resizing columns
2) Respond to column sizing changes and check if the grid is displaying a scroll bar. If it is, add the height of the scroll bar to the control, otherwise remove it.
The way to do the second is as follows.
Firstly, you can detect if there is a scroll bar using code like this (really there should be properties which do this automatically):
lStyle = GetWindowLong(grd.hWnd, GWL_STYLE)
If (lStyle And WS_HSCROLL) = WS_HSCROLL Then
' grid has horizontal scroll
End If
If (lStyle And WS_VSCROLL) = WS_VSCROLL Then
' grid has vertical scroll
End If
With that info, you can now determine the extra room in the control required for the scroll bar using the GetSystemMetrics call using SM_CYHSCROLL (vertical size of horizontal scroll bar) and SM_CXVSCROLL (horizontal size of vertical scroll bar).
As for the second bug, I will look into it.
|