I would like to put cinco controles picturebo
x aligned just in the top middle of the screen. (The length of the screen is different for each user).
To begin with, my idea is that the window is maximizada
, to obtain the total size of form
. (The form
will be transparente
, with its property backcolor
), hence you need to place the 5 imagenes
right in the medio superior
of the screen.
My idea was that once I got the measure in pixeles totales
, I would divide it in two, and challenge half the length of the first control.
So, if the longitud
is 1000
, and the imagen
is 50x50
, you would have to put it from 1000/2 -25 = 475
.
The image would be located between the pixel 475
and the 525
. Perfectly aligned.
This is the code:
int tamañoimg = Invocador1.Size.Height;
int centro = this.Height / 2 - ( tamañoimg / 2 );
Invocador1.Left = centro;
But the position is not exactly half, but roughly 1/4 to the right.
Reading, I have heard that it could be that when the form is loaded, it still does not get the number of real pixels when maximizing the window.
How could I solve it?