• Hello Guest! Welcome to ConsoleCrunch, to help support our site check out the premium upgrades HERE! to get exclusive access to our hidden content.
  • Unable to load portions of the website...
    If you use an ad blocker addon, you should disable it because it interferes with several elements of the site and blocks more than just adverts.
  • Read Rules Before Posting Post Virus Scans with every program.

Moving a custom border with no border style[c#]

Psycho_Coder

Active Poster
Retired Staff
Active Member
3qfzIyk.png


Here is a little border I made out of a PictureB ox, You can simple move it around.

Source:

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication6
{
    public partial class Form1 : Form
    {
        int border;
        int MoveX;
        int MoveY;
        public Form1()
        {
            InitializeComponent();
           
        }

        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            border = 1;
            MoveX = e.Y;
            MoveY = e.Y;

        }

        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            border = 0;
        }

        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            if (border == 1)
            {
                this.SetDesktopLocation(MousePosition.X - MoveX, MousePosition.Y - MoveY); 
            }
        }
    }
}

 
General chit-chat
Help Users
      Chat Bot: arkoh is our newest member. Welcome!
      Back
      Top