Form mouse move event : Form Event : GUI Windows Forms C# Examples


C# Examples » GUI Windows Forms » Form Event »

 

Form mouse move event









    
using  System;
using  System.Drawing;
using  System.Collections;
using  System.ComponentModel;
using  System.Windows.Forms;
using  System.Data;

public  class  FormMouseMoveEvent  :  System.Windows.Forms.Form
{
    private  System.ComponentModel.Container  components  =  null;

    public  FormMouseMoveEvent()
    {

        this.MouseMove  +=  new  MouseEventHandler(OnMouseMove);
        InitializeComponent();
    }

    protected  override  void  Dispose(  bool  disposing  )
    {
        if(  disposing  )
        {
            if  (components  !=  null)  
            {
                components.Dispose();
            }
        }
        base.Dispose(  disposing  );        
    }

    private  void  InitializeComponent()
    {
        this.components  =  new  System.ComponentModel.Container();
        this.Size  =  new  System.Drawing.Size(300,300);
        this.Text  =  "Form1";
    }

    [STAThread]
    static  void  Main()  
    {
        Application.Run(new  FormMouseMoveEvent());
    }

    protected  void  OnMouseMove(object  sender,  MouseEventArgs  e)
    {
        this.Text  =  "Current  Pos:  ("  +  e.X  +  ",  "  +  e.Y  +  ")";
    }

}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo GUI Windows Forms
» Form Event