Center image in form

  • Thread starter Thread starter Alberto Salvati
  • Start date Start date
A

Alberto Salvati

Hi, all.
i need an image on my application's mai form.
This image needs center form position.
So, i try to compute X with a formula like this:

X = (myformwidth - myimagewidth)/2

I get form client area bound, form width and so on, but this code
fails.
Each time I see my image in wrong location.

TIA for any answer.

A. Salvati
 
Alberto Salvati skrev:
Hi, all.
i need an image on my application's mai form.
This image needs center form position.
So, i try to compute X with a formula like this:

X = (myformwidth - myimagewidth)/2

I get form client area bound, form width and so on, but this code
fails.
Each time I see my image in wrong location.

TIA for any answer.
Is the image automatically scaled after setting the position?
 
Hi, Bjørn.

I dont' understand what means "Is the image automatically scaled".. :-
(((

But, I see other strange situations.
Fox example...
In my form I manage resize event to enlarge textbox when user opens
ppc keyboard.
So, when resize even occurs, i compute a new width for my textboxes.
But, each time I do it, i MUST include in formula a "magic numer", 32,
to get valid value for textbox size.
If I exclude this "32" in "landscape" mode, my textbox is too large
and goes out of screen area...
If I exlude this "32" in "portrait" mode, I haven't original textbox
size.

TIA

Alberto Salvati
 
Alberto Salvati skrev:
Hi, Bjørn.

I dont' understand what means "Is the image automatically scaled".. :-
(((

The PictureBox object have a SizeMode parameter telling how the image is
displayed where the values is one of: Normal, StretchImage and CenterImage
But, I see other strange situations.
Fox example...
In my form I manage resize event to enlarge textbox when user opens
ppc keyboard.
So, when resize even occurs, i compute a new width for my textboxes.
But, each time I do it, i MUST include in formula a "magic numer", 32,
to get valid value for textbox size.
If I exclude this "32" in "landscape" mode, my textbox is too large
and goes out of screen area...
If I exlude this "32" in "portrait" mode, I haven't original textbox
size.
Personally I always trust a proper use of Anchor manages scaling and
rotation of my forms.
 
Alberto Salvati skrev:



The PictureBox object have a SizeMode parameter telling how the image is
displayed where the values is one of: Normal, StretchImage and CenterImage

uhm...
Using normal or strectch I've not changes.
I'll try "center" later



Personally I always trust a proper use of Anchor manages scaling and
rotation of my forms.

... but if I've a label on left side of textbox I see a lot of space
bertween label and textbox.


Tnx.


AS
 
Alberto Salvati skrev:
uhm...
Using normal or strectch I've not changes.
I'll try "center" later





.. but if I've a label on left side of textbox I see a lot of space
bertween label and textbox.
The label does also have an Anchor attribute.

A balanced use of the Anchor attributes does almost resolve my problems,
- hard coding adjustments may work, but if the program is installed on a
unit with a different screen resolution, different default font size and
so on you always ends up in trouble.

In your case: in a "row" you have a Label followed by a TextBox: If you
want the TextBox to be the dynamic sized field you set the Label Anchor
to Top+Left, and the TextBox Anchor to Top+Left+Right.
 
Back
Top