Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8510657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:45:55+00:00 2026-06-11T03:45:55+00:00

I would like to send a control to back of its container. Regardless some

  • 0

I would like to send a control to back of its container. Regardless some other controls are created and removed from the same container, I dont want this control to loose its position.

I dont have any better way to achieve this :

// Force this control to stay back 
private void panel1_ControlAdded(object sender, ControlEventArgs e) 
{
    pictureBox1.SendToBack(); 
}

It looks overkill to me. Is it a better way to achieve this ?

EDIT:

I am told that controls.add put controls in front by default. I cannot reproduce this behavior, or I miss the point somewhere. Here is what I tried :

using System;
using System.Drawing;
using System.Windows.Forms;

namespace WindowsFormsApplication4
{
    public partial class Form1 : Form
    {
        System.Windows.Forms.Button button1;

        public Form1() { InitializeComponent(); }

        void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(225, 182);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(139, 39);
            this.button1.TabIndex = 0;
            this.button1.Text = "button1";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // pictureBox1
            // 
            this.pictureBox1.Image = global::WindowsFormsApplication4.Properties.Resources.Tulips;
            this.pictureBox1.Location = new System.Drawing.Point(36, 26);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(299, 175);
            this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            this.pictureBox1.TabIndex = 1;
            this.pictureBox1.TabStop = false;
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(376, 233);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.pictureBox1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
            this.ResumeLayout(false);

        }

        private PictureBox pictureBox1;

        Point xy;

        // Add a button or anything else
        private void button1_Click(object sender, EventArgs e)
        {
            var ctl = new Button();
            ctl.Location = xy;

            this.Controls.Add(ctl);

            xy.Offset(10, 10);
        }

        // First of all, send the picture box to back
        private void Form1_Load(object sender, EventArgs e)
        {
            pictureBox1.SendToBack();
        }
    }
}

So as you can notice, as I hit button1 several times, the newly added buttons (can replaced by textboxes…) goes behind the picturebox that has been sent to back in the Load event. So I definitely cannot rely on Control.Add supposed default behavior.

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:45:56+00:00Added an answer on June 11, 2026 at 3:45 am

    As this trick seems to do its job fine after some days of tests, I feel no need to dig further.

    // Force this control to stay back  
    private void panel1_ControlAdded(object sender, ControlEventArgs e)  
    { 
        pictureBox1.SendToBack();  
    }
    

    However, I still wonder why Control.Add does not behaves the way it should.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to send email from an address I control, but currently this
I would like to send the message from HelloWorldLayer, and receive it in ScoreLayer,
I would like to send a struct from my client program to a server
I have completed my program and would like to send that program in its
I would like to send keys to a c# web browser control element directly,
I made a form and created a command button control. I would like to
I would like to get some tips from peer developers about how you go
I would like to send a BackSpace control char to a TMemo like the
I would like to control and embed my send() calls in a try/except, but
I would like to send a javascript array to be processed by a method

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.