SIGN UP MEMBER LOGIN:    
ARTICLE

Move Windows Form Without Border

Posted by Kirtan Patel Articles | Windows Forms C# December 06, 2009
Some time its necessary that we want to move form without border. So here is the solution to move that type of form.
Reader Level:
Download Files:
 

Introduction 


Some time its necessary that we want to move windows form without border. Especially when we making our form in abnormal shape rather then the normal rectangular shape. Hence we need to hide the Title bar of form and we can move the form from its Place. So here is the solution that how we can move that type of form.

Windows form will look like below:



Platform 

C# 2.0/3.5

Explanation of Implemented Logic

When we mouse click the form and hold it we will have 1 flag variable. We will make it true, then when we release the mouse click on form area we will set the flag to false; now when mouse moves then we will check if mouse click is hold or not by that flag variable. If the variable is true then make the form location same as Cursor location. That's it, so simple.

So lets see how to do it  by code

namespace MoveFormWithoutBoard

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        bool flag = false;

        private void Form1_MouseDown(object sender, MouseEventArgs e)

        { 

            flag = true;

        } 

        private void Form1_MouseMove(object sender, MouseEventArgs e)

        {

            //Check if Flag is True ??? if so then make form position same

            //as Cursor position

            if (flag == true)

            {

                this.Location = Cursor.Position; 

            }

        } 

        private void Form1_MouseUp(object sender, MouseEventArgs e)

        {

            flag = false;

        }

    }

}


Conclusion


This article explains the logic about how to move form without any border.

Login to add your contents and source code to this article
share this article :
post comment
 

I use this code for an WPF App whitout borders:

private void Window_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)

{this.DragMove();}

Posted by Javier Yague Feb 23, 2010
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Become a Sponsor