- Local time
- Today, 03:13
- Joined
- Feb 19, 2013
- Messages
- 16,658
I'm just reviewing my form layout functions and wondered if I can simplify the code.
The basic concept is I divide the form into areas on a grid system. Simplistically top left, top right, bottom left, bottom right.
if a form is resized (typically width is narrowed) so all the controls are not shown, controls in top right are moved and inserted below top left, bottom left is moved down to accommodate and bottom right moved to below bottom left.
The real world requirement for this is having a form that is equally usable on a PC screen (typically 19"+) and a tablet - not only a smaller screen, but controls have to be larger to accommodate the lack of precision with using a finger instead of a mouse. You see the principle frequently with web pages on phones.
To design for the smaller tablet screen (which will utilise more vertical scrolling) and apply to a larger screen can make it look rather 'inefficient'.
At the moment when a form opens I loop through the controls to identify which controls belong to which 'section' (based on their top/left properties)and put them in an appropriate collection. I don't use layouts.
When the form is resized, code loops through the collections to reposition the controls. All works fine but as I said I am reviewing it.
It occurred to me that maybe if I used layouts, I could use the layoutID instead of the control top/left properties to move controls wholesale rather than individually. I would need to know the layout top/left/height/width properties and these would need to be updateable (not read only).
From my investigations, If (using vba) I move a single control in a layout with multiple controls, all the controls move, but only vertically, not horizontally. So a halfway step.
To address the lack of horizontal movement, I'm wondering if the layout properties can be accessed, but I can't find them. I've looked in form properties and tried to find an appropriate collection but to no avail.
I've looked on line using keywords like 'form collections', 'properties', 'layouts' etc but perhaps not found the right keyword.
Any suggestions?
The basic concept is I divide the form into areas on a grid system. Simplistically top left, top right, bottom left, bottom right.
if a form is resized (typically width is narrowed) so all the controls are not shown, controls in top right are moved and inserted below top left, bottom left is moved down to accommodate and bottom right moved to below bottom left.
The real world requirement for this is having a form that is equally usable on a PC screen (typically 19"+) and a tablet - not only a smaller screen, but controls have to be larger to accommodate the lack of precision with using a finger instead of a mouse. You see the principle frequently with web pages on phones.
To design for the smaller tablet screen (which will utilise more vertical scrolling) and apply to a larger screen can make it look rather 'inefficient'.
At the moment when a form opens I loop through the controls to identify which controls belong to which 'section' (based on their top/left properties)and put them in an appropriate collection. I don't use layouts.
When the form is resized, code loops through the collections to reposition the controls. All works fine but as I said I am reviewing it.
It occurred to me that maybe if I used layouts, I could use the layoutID instead of the control top/left properties to move controls wholesale rather than individually. I would need to know the layout top/left/height/width properties and these would need to be updateable (not read only).
From my investigations, If (using vba) I move a single control in a layout with multiple controls, all the controls move, but only vertically, not horizontally. So a halfway step.
To address the lack of horizontal movement, I'm wondering if the layout properties can be accessed, but I can't find them. I've looked in form properties and tried to find an appropriate collection but to no avail.
I've looked on line using keywords like 'form collections', 'properties', 'layouts' etc but perhaps not found the right keyword.
Any suggestions?