0

I currently encountered problems with a Windows Form project I realize in C# with Visual Studio 2019.

Here is my Form :

My form

When I start the app with my screen resolution (3840x2160) everything seems ok :

enter image description here

But when I start the app with another screen resolution (1920x1080) there is a problem:

enter image description here

PictureBoxes of my CustomControl have disappear... I don't understand why ! My picutreboxes Anchor property is set to Top,Right ! And they don't stay on the right correctly..

Notice that there is no problem with the picturebox on the bottom right of my footer panel.

So the question is : why with a differnt screen resolution, pictureboxes of my customcontrol disappear ?

Thank You very much if you find any solution to this problem...

[EDIT]

Remove the anchor and try manually placing your custom control to the desired location.

If I do that here is what happen :

enter image description here

[EDIT]

Here are my form and customcontrol properties :

1 - In high resoluion (3840x2160). Everything is ok :

enter image description here

2 - In low resolution (1920x1080). pictureboxes are out of the customcontrol

enter image description here

In both cases, the customcontrol has right dimensions. The problem comes from pictureboxes who are not located properly when screen size is 1920x1080

[EDIT]

[SOLUTION]

Edit picturebox location manually and don't trust in anhchor property lol

Hugo H
  • 30
  • 3

1 Answers1

0

Add this to the CustomControl below InitializeComponent(); and the control will always show up in the upper right corner.

pictureBox.Location=new Point(this.Width-(pictureBox.Width+16),0);

Sometimes it may also need pictureBox.BringToFront;

Make sure to rebuild your solution and add the CustomControl(or UserControl whatever) again to get the new updated control.

Community
  • 1
  • 1
D J
  • 845
  • 1
  • 13
  • 27
  • Doesn't works, see my update, problem comes from pictureboxes location and not customcontrol size or location – Hugo H Apr 27 '20 at 12:13
  • @HugoH: I think, if you add the same to the CustomControl, it may solve the problem. I have edited my answer. Pls try it. – D J Apr 27 '20 at 12:16
  • Yes works when I put manually picturebox location. It was the job of the anchor property but i will set manually the location. Thank You – Hugo H Apr 27 '20 at 12:20
  • @HugoH If this works, pls mark as answer for others to get help in need. – D J Apr 27 '20 at 12:21
  • Done, Thank You @D J – Hugo H Apr 27 '20 at 12:23