0

I have a panel with blue background. And have to add a glcontrol inside this panel. Above this glcontrol, I have to show a transparent circle image. I have tried like below. But transparency of circle is missing. How to add a transparent image on top of glcontrol ?

        this.panel1.BackColor = System.Drawing.Color.DarkTurquoise;
        this.panel1.Controls.Add(this.pictureBox2);
        this.panel1.Controls.Add(this.glControl1);
        this.panel1.Location = new System.Drawing.Point(610, 510);
        this.panel1.Name = "panel1";
        this.panel1.Size = new System.Drawing.Size(200, 178);
        this.panel1.TabIndex = 16;

       // pictureBox2 // CIRCLE IMAGE
        // 
        this.pictureBox2.BackColor = System.Drawing.Color.Transparent;
        this.pictureBox2.Image = global::Prism.Properties.Resources.circle;
        this.pictureBox2.Location = new System.Drawing.Point(54, 69);
        this.pictureBox2.Name = "pictureBox2";
        this.pictureBox2.Size = new System.Drawing.Size(100, 50);
        this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
        this.pictureBox2.TabIndex = 14;
        this.pictureBox2.TabStop = false;
        // 
        // glControl1 
        // 
            this.glControl1.BackColor = System.Drawing.Color.Transparent;
        this.glControl1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
        this.glControl1.Location = new System.Drawing.Point(39, 27);
        this.glControl1.Margin = new System.Windows.Forms.Padding(0);
        this.glControl1.Name = "glControl1";
        this.glControl1.Size = new System.Drawing.Size(304, 205);
        this.glControl1.TabIndex = 0;
        this.glControl1.VSync = false;
        // 

On code behind,

        glControl1.Controls.Add(pictureBox2);
        pictureBox2.BringToFront();
        glControl1.SendToBack();

enter image description here

user2431727
  • 877
  • 2
  • 15
  • 46
  • You can stack picturebox controls like `pictureBox1.Controls.Add(pictureBox2)`. you may also want to take a look at [`TransparentPictureBox`](https://stackoverflow.com/a/36102074/3110834). – Reza Aghaei Mar 02 '20 at 07:29
  • It is working for picture box on top of other picture box. My issue is with picture box on top of glcontrol. I have added glControl1.Controls.Add(pictureBox2); – user2431727 Mar 02 '20 at 07:56
  • `TransparentPictureBox` works without stacking. It's enough to position it on top of any control. – Reza Aghaei Mar 02 '20 at 08:03

0 Answers0