Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Runtime ToFront toBack?

Runtime ToFront toBack?

Scheduled Pinned Locked Moved C#
graphicscsharplinqdesignhelp
8 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dennis_max27
    wrote on last edited by
    #1

    I've made a picturebox where I have a runtime code in. There i open a other Picturebox, but that picturebox I run runtime from the Design Picturebox is under the design picturebox and must be at the top. Hope somebody can help. Dennis,

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace KVzoekscherm
    {
    public partial class runtimeobject : Form
    {
    Button button1;
    Button button2;
    Bitmap image1;
    PictureBox pictureBox1;

        public runtimeobject()
        {
            InitializeComponent();
        }
    
        //Deze functie roept hij op wanneer hij over de (grote) picturebox gaat
        private void pbMaak\_Click(object sender, EventArgs e)
        {
            pictureBox1 = new PictureBox();
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            pictureBox1.BorderStyle = BorderStyle.None;
            pictureBox1.ClientSize = new Size(15, 15);
            pictureBox1.Location = new System.Drawing.Point(50, 50);
            pictureBox1.Cursor = Cursors.Hand;
            pictureBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
            pictureBox1.TabIndex = 28;
    
            image1 = new Bitmap(Properties.Resources.edit\_gray);
            pictureBox1.Image = (Image)image1;
    
            pictureBox1.Click += new EventHandler(editclick);
            pictureBox1.MouseLeave += new EventHandler(editleave);
            pictureBox1.MouseEnter += new EventHandler(editenter);
            this.Controls.Add(pictureBox1);
        }
    
        private void editenter(object sender, EventArgs e)
        {
            image1 = new Bitmap(Properties.Resources.edit\_color);
            pictureBox1.Image = (Image)image1;
        }
    
        private void editleave(object sender, EventArgs e)
        {
            image1 = new Bitmap(Properties.Resources.edit\_gray);
            pictureBox1.Image = (Image)image1;
        }
    
        private void editclick(object sender, EventArgs e)
        {
            MessageBox.Show("Clicked");
        }
    
        private void runtimeobject\_Load(object sender, EventArgs e)
        {
    
        }
    
        private void pbMaak\_Click\_1(object sender, EventArgs e)
        {
    
        }
    }
    

    }

    S D 2 Replies Last reply
    0
    • D dennis_max27

      I've made a picturebox where I have a runtime code in. There i open a other Picturebox, but that picturebox I run runtime from the Design Picturebox is under the design picturebox and must be at the top. Hope somebody can help. Dennis,

      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Linq;
      using System.Text;
      using System.Windows.Forms;

      namespace KVzoekscherm
      {
      public partial class runtimeobject : Form
      {
      Button button1;
      Button button2;
      Bitmap image1;
      PictureBox pictureBox1;

          public runtimeobject()
          {
              InitializeComponent();
          }
      
          //Deze functie roept hij op wanneer hij over de (grote) picturebox gaat
          private void pbMaak\_Click(object sender, EventArgs e)
          {
              pictureBox1 = new PictureBox();
              pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
              pictureBox1.BorderStyle = BorderStyle.None;
              pictureBox1.ClientSize = new Size(15, 15);
              pictureBox1.Location = new System.Drawing.Point(50, 50);
              pictureBox1.Cursor = Cursors.Hand;
              pictureBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
              pictureBox1.TabIndex = 28;
      
              image1 = new Bitmap(Properties.Resources.edit\_gray);
              pictureBox1.Image = (Image)image1;
      
              pictureBox1.Click += new EventHandler(editclick);
              pictureBox1.MouseLeave += new EventHandler(editleave);
              pictureBox1.MouseEnter += new EventHandler(editenter);
              this.Controls.Add(pictureBox1);
          }
      
          private void editenter(object sender, EventArgs e)
          {
              image1 = new Bitmap(Properties.Resources.edit\_color);
              pictureBox1.Image = (Image)image1;
          }
      
          private void editleave(object sender, EventArgs e)
          {
              image1 = new Bitmap(Properties.Resources.edit\_gray);
              pictureBox1.Image = (Image)image1;
          }
      
          private void editclick(object sender, EventArgs e)
          {
              MessageBox.Show("Clicked");
          }
      
          private void runtimeobject\_Load(object sender, EventArgs e)
          {
      
          }
      
          private void pbMaak\_Click\_1(object sender, EventArgs e)
          {
      
          }
      }
      

      }

      S Offline
      S Offline
      Saksida Bojan
      wrote on last edited by
      #2

      Use this to move control to the back

      pictureBox1.SendToBack();

      Edit: I suggest you use Name property. If you intended to use Controls to search through controls. It will be easier to get the desired control.

      pictureBox1.Name = "pictureBox1";

      D 1 Reply Last reply
      0
      • S Saksida Bojan

        Use this to move control to the back

        pictureBox1.SendToBack();

        Edit: I suggest you use Name property. If you intended to use Controls to search through controls. It will be easier to get the desired control.

        pictureBox1.Name = "pictureBox1";

        D Offline
        D Offline
        dennis_max27
        wrote on last edited by
        #3

        But: pictureBox1.SendToBack(); I will need to send pictureBox1 to the front :P That option doesn't Exist. SendToFront :(

        S 1 Reply Last reply
        0
        • D dennis_max27

          But: pictureBox1.SendToBack(); I will need to send pictureBox1 to the front :P That option doesn't Exist. SendToFront :(

          S Offline
          S Offline
          Saksida Bojan
          wrote on last edited by
          #4

          it is: BringToFront()

          D 1 Reply Last reply
          0
          • S Saksida Bojan

            it is: BringToFront()

            D Offline
            D Offline
            dennis_max27
            wrote on last edited by
            #5

            II've used this code now all is working BUT!: Here is is coming: If i mouseenter and mouseleave it now it is changing the image and if i disable the Bring toFront it is working?

            using System;
            using System.Collections.Generic;
            using System.ComponentModel;
            using System.Data;
            using System.Drawing;
            using System.Linq;
            using System.Text;
            using System.Windows.Forms;

            namespace KVzoekscherm
            {
            public partial class runtimeobject : Form
            {
            Button button1;
            Button button2;
            Bitmap image1;
            PictureBox pictureBox1;

                public runtimeobject()
                {
                    InitializeComponent();
                }
            
                //Deze functie roept hij op wanneer hij over de (grote) picturebox gaat
                private void pbMaak\_Click(object sender, EventArgs e)
                {
                    pictureBox1 = new PictureBox();
                    pictureBox1.Name = "pictureBox1";
                    pictureBox1.BringToFront();
                    pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                    pictureBox1.BorderStyle = BorderStyle.None;
                    pictureBox1.ClientSize = new Size(15, 15);
                    pictureBox1.Location = new System.Drawing.Point(50, 50);
                    pictureBox1.Cursor = Cursors.Hand;
                    pictureBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
                    pictureBox1.TabIndex = 28;
            
                    image1 = new Bitmap(Properties.Resources.edit\_gray);
                    pictureBox1.Image = (Image)image1;
            
                    pictureBox1.Click += new EventHandler(editclick);
                    pictureBox1.MouseLeave += new EventHandler(editleave);
                    pictureBox1.MouseEnter += new EventHandler(editenter);
                    this.Controls.Add(pictureBox1);
                }
            
                private void editenter(object sender, EventArgs e)
                {
                    image1 = new Bitmap(Properties.Resources.edit\_color);
                    pictureBox1.Image = (Image)image1;
                }
            
                private void editleave(object sender, EventArgs e)
                {
                    image1 = new Bitmap(Properties.Resources.edit\_gray);
                    pictureBox1.Image = (Image)image1;
                }
            
                private void editclick(object sender, EventArgs e)
                {
                    MessageBox.Show("Clicked");
                }
            
                private void runtimeobject\_Load(object sender, EventArgs e)
                {
            
                }
            
                private void pbMaak\_Click\_1(object sender, EventArgs e)
                {
            
                }
            }
            

            }

            S 1 Reply Last reply
            0
            • D dennis_max27

              II've used this code now all is working BUT!: Here is is coming: If i mouseenter and mouseleave it now it is changing the image and if i disable the Bring toFront it is working?

              using System;
              using System.Collections.Generic;
              using System.ComponentModel;
              using System.Data;
              using System.Drawing;
              using System.Linq;
              using System.Text;
              using System.Windows.Forms;

              namespace KVzoekscherm
              {
              public partial class runtimeobject : Form
              {
              Button button1;
              Button button2;
              Bitmap image1;
              PictureBox pictureBox1;

                  public runtimeobject()
                  {
                      InitializeComponent();
                  }
              
                  //Deze functie roept hij op wanneer hij over de (grote) picturebox gaat
                  private void pbMaak\_Click(object sender, EventArgs e)
                  {
                      pictureBox1 = new PictureBox();
                      pictureBox1.Name = "pictureBox1";
                      pictureBox1.BringToFront();
                      pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                      pictureBox1.BorderStyle = BorderStyle.None;
                      pictureBox1.ClientSize = new Size(15, 15);
                      pictureBox1.Location = new System.Drawing.Point(50, 50);
                      pictureBox1.Cursor = Cursors.Hand;
                      pictureBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
                      pictureBox1.TabIndex = 28;
              
                      image1 = new Bitmap(Properties.Resources.edit\_gray);
                      pictureBox1.Image = (Image)image1;
              
                      pictureBox1.Click += new EventHandler(editclick);
                      pictureBox1.MouseLeave += new EventHandler(editleave);
                      pictureBox1.MouseEnter += new EventHandler(editenter);
                      this.Controls.Add(pictureBox1);
                  }
              
                  private void editenter(object sender, EventArgs e)
                  {
                      image1 = new Bitmap(Properties.Resources.edit\_color);
                      pictureBox1.Image = (Image)image1;
                  }
              
                  private void editleave(object sender, EventArgs e)
                  {
                      image1 = new Bitmap(Properties.Resources.edit\_gray);
                      pictureBox1.Image = (Image)image1;
                  }
              
                  private void editclick(object sender, EventArgs e)
                  {
                      MessageBox.Show("Clicked");
                  }
              
                  private void runtimeobject\_Load(object sender, EventArgs e)
                  {
              
                  }
              
                  private void pbMaak\_Click\_1(object sender, EventArgs e)
                  {
              
                  }
              }
              

              }

              S Offline
              S Offline
              Saksida Bojan
              wrote on last edited by
              #6

              If there is control on top of yours, it should affect Mouseenter and MouseLeave events, but I am starting with a job, so I Cant help you now and test it

              D 1 Reply Last reply
              0
              • S Saksida Bojan

                If there is control on top of yours, it should affect Mouseenter and MouseLeave events, but I am starting with a job, so I Cant help you now and test it

                D Offline
                D Offline
                dennis_max27
                wrote on last edited by
                #7

                Yes im trying some things do will say when it is owkring here. Now waiting for somebody else his help. Thanks!

                1 Reply Last reply
                0
                • D dennis_max27

                  I've made a picturebox where I have a runtime code in. There i open a other Picturebox, but that picturebox I run runtime from the Design Picturebox is under the design picturebox and must be at the top. Hope somebody can help. Dennis,

                  using System;
                  using System.Collections.Generic;
                  using System.ComponentModel;
                  using System.Data;
                  using System.Drawing;
                  using System.Linq;
                  using System.Text;
                  using System.Windows.Forms;

                  namespace KVzoekscherm
                  {
                  public partial class runtimeobject : Form
                  {
                  Button button1;
                  Button button2;
                  Bitmap image1;
                  PictureBox pictureBox1;

                      public runtimeobject()
                      {
                          InitializeComponent();
                      }
                  
                      //Deze functie roept hij op wanneer hij over de (grote) picturebox gaat
                      private void pbMaak\_Click(object sender, EventArgs e)
                      {
                          pictureBox1 = new PictureBox();
                          pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                          pictureBox1.BorderStyle = BorderStyle.None;
                          pictureBox1.ClientSize = new Size(15, 15);
                          pictureBox1.Location = new System.Drawing.Point(50, 50);
                          pictureBox1.Cursor = Cursors.Hand;
                          pictureBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
                          pictureBox1.TabIndex = 28;
                  
                          image1 = new Bitmap(Properties.Resources.edit\_gray);
                          pictureBox1.Image = (Image)image1;
                  
                          pictureBox1.Click += new EventHandler(editclick);
                          pictureBox1.MouseLeave += new EventHandler(editleave);
                          pictureBox1.MouseEnter += new EventHandler(editenter);
                          this.Controls.Add(pictureBox1);
                      }
                  
                      private void editenter(object sender, EventArgs e)
                      {
                          image1 = new Bitmap(Properties.Resources.edit\_color);
                          pictureBox1.Image = (Image)image1;
                      }
                  
                      private void editleave(object sender, EventArgs e)
                      {
                          image1 = new Bitmap(Properties.Resources.edit\_gray);
                          pictureBox1.Image = (Image)image1;
                      }
                  
                      private void editclick(object sender, EventArgs e)
                      {
                          MessageBox.Show("Clicked");
                      }
                  
                      private void runtimeobject\_Load(object sender, EventArgs e)
                      {
                  
                      }
                  
                      private void pbMaak\_Click\_1(object sender, EventArgs e)
                      {
                  
                      }
                  }
                  

                  }

                  D Offline
                  D Offline
                  dennis_max27
                  wrote on last edited by
                  #8

                  Sombody?

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups