[program-l] Re: VB: Laying out items
- From: "Will Pearson" <will-pearson@xxxxxxxxxxxxx>
- To: <program-l@xxxxxxxxxxxxx>
- Date: Thu, 22 Sep 2005 14:06:15 +0100
Hi Che,
Yes, there's nothing wrong in sizing your controls using code, even creating
controls on your form using code. It's often common place for someone to at
least modify the initial sizes and locations of controls in response to
various events the user invokes, say resizing a form, and creating controls
dynamically using code allows someone to modify the display in response to
the current state of the application.
Within the code there's various properties to modify positions and sizes:
Height
Width
Top
Bottom
Left
Right
Size
Location
Plus there's some more that are useful if you are creating your own
controls, i.e.. you're not using the system supplied control classes such as
button controls, edit controls, etc.
Sizing controls in code offers one advantage over the Windows Forms
designer, at least for a blind person. You can use:
System.Drawing.Graphics.MeasureString
to work out the height and width of a text string. This allows you to
determine what the height and width of a control should be in order to fit
in a text string that you wish to have as a label, item, etc. You can then
add any spacing you wish to have between the text and the control's border,
and you have then worked out the size for the control. One tip that I have
if you decide to take the code route, is to use math to work out where each
control should be located and it's size. Position your first control
relative to a point on the form, and then each control's location should be
relative to other controls that you have already positioned on the form.
This formulaic approach is useful if you want to reposition your controls
when the user resizes the form, as all you have to do is alter a few
variables in the calculation and then re-run the algorithm. When a user
resizes a form you can do one of three things:
1. Not allow them to resize the form, i.e.. have it at a constant fixed size
2. Reposition, and maybe resize, your controls to fit them into the new area
of the form
3. Leave the control's positions and sizes as they were originally, covering
up any non-visible areas if they shrink the form's size, or leaving a margin
of whitespace should they expand the form's size beyond the original size
which one is appropriate is up to how you want to design your application.
If you want to use the Windows Forms designer, then once you've selected the
control you wish to move or resize, select properties from the context menu
and alter the properties associated with the location and size. Using the
Windows Forms designer can be a quicker method to using code, and has the
advantage of allowing you to show the form's design to someone and getting
their feedback on whether it looks OK without having to put in all the code
to create and successfully compile the code for the form.
Working in the field of human computer interaction, I would encourage you to
layout a form according to the needs and expectations of your target users.
A couple of useful tricks are not to cram too many things close together, as
this hinders a user's ability to quickly visually differentiate between the
different controls, e.g.. two buttons placed very close together could be
perceived as one big button if they are too close together. The second
trick is to group controls that have similar functionality, or perform
actions on the same object, together by having less spacing between these
controls than you would controls that have very distinctive functionality
from one another, something that again is a trick that leverages perceptual
psychology.
Will
----- Original Message -----
From: "Che" <che@xxxxxxxxxxxxxxxx>
To: <program-l@xxxxxxxxxxxxx>
Sent: Wednesday, September 21, 2005 8:44 PM
Subject: [program-l] VB: Laying out items
So how do blind programmers lay out their design form in studio? I know
you can move items with the arrow keys and all, but how do you tell if
things are laid out properly, or lined up and so forth. For instance, how
do you line up labels with appropriate text fields?
Thanks for any advice,
Signed,
Slowly making progress
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq
Other related posts: