• Marc
  • Member Topic Starter
Hi Igor

I would like to set an iGrid control's height the way it shows all rows, i.d. there should be no need to scroll vertically.

I tried to calculate and set the control's height as follows:

ctrl.Width = PixelsToTwips(grd.Sys(igSysRowsVisScrollHeight) + (grd.Sys(igSysClientAreaHeight) _
     - grd.Sys(igSysCellsAreaHeight)), gsaDirectionVertical) _
     + ctrl.TopPadding + ctrl.BottomPadding

PixelsToTwips() is a function to convert pixel values to Twips:
Public Function PixelsToTwips(lPixels As Long, lDirection As TScreenDirection) As Long
    Dim lngDeviceHandle As Long
    Dim lPixelsPerInch As Long
    lngDeviceHandle = GetDC(0) 'API function
    If lDirection = TScreenDirection.gsaDirectionHorizontal Then
        lPixelsPerInch = GetDeviceCaps(lngDeviceHandle, 88) 'API function
        lPixelsPerInch = GetDeviceCaps(lngDeviceHandle, 90) 'API function
    End If
    lngDeviceHandle = ReleaseDC(0, lngDeviceHandle) 'API function
    PixelsToTwips = lPixels * 1440 / lPixelsPerInch
End Function

The result comes close but I still seem to neglect something, i.e. I still have to scroll a bit.
Do you have any hint for me?


PS. I'm developing with Access 2010.
I do not see that you take into account the control border width, 2 pixels from each side for the standard 3D border.