Bonsoir à tous..

je suis confronté à un problème.. j'ai un code qui me permet de générer des pictureBox pour pouvoir afficher toutes mes images dans une forms, mais je n'arrive pas à les aligner correctement..


j'obtiens ca :



alors que je voudrais ca :



voici le code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 
public partial class frmImages : Form
    {
        private GroupBox groupBox1;
 
        private readonly int PicBoxHeight = 0x113;
        private readonly int PicBoxLeft1 = 3;
        private readonly int PicBoxLeft2 = 0x17d;
        private readonly int PicBoxWidth = 0x177;
 
        private Panel pnlImageBox;
        public string SelectedImage;
 
        private void FillImages()
        {
            PictureBox box = null;
            int num = 0;
            int num2 = 0;
            int num3 = 0;
 
            foreach (Thumb MyImage in _Film.Fanart)
            {
                switch (num3)
                {
                    case 2:
                        num = 0x11d;
                        num3 = 0;
                        break;
 
                    case 0:
                        num2 = this.PicBoxLeft1;
                        goto Label_006A;
                }
                num2 = this.PicBoxLeft2;
 
 
            Label_006A:
 
                box = new PictureBox();
                this.pnlImageBox.Controls.Add(box);
                box.Left = num2;
                box.Top = num;
                box.Height = this.PicBoxHeight;
                box.Width = this.PicBoxWidth;
                box.Tag = MyImage.url;
                box.ImageLocation = MyImage.url;
                Image Test = Image.FromFile(@"c:\test.jpg");
                box.InitialImage = Test;
                box.BorderStyle = BorderStyle.None;
                box.SizeMode = PictureBoxSizeMode.Zoom;
 
                box.Click += new EventHandler(this.PicBox_Click);
                box.DoubleClick += new EventHandler(this.PicBox_DoubleClick);
 
                num3++;
            }
        }
 
    }
merci d'avance de votre aide.. bonne soirée à tous :-)