Hi, all i have to make an application in which there is requirement to hide a cursor when a event is generated and cursor enters a panel, and if the mouse is clicked in the panel, the cursor has to be show again. But i am unable to do this. any help would be appreciated, thanks in advance.:)

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

namespace CursorHide
{
    public partial class Form1 : Form
    {
        private bool flag;

        public Form1()
        {
            InitializeComponent();
        }

        private void panel1_MouseUp(object sender, MouseEventArgs e)
        {
            flag = false;
            Cursor.Show();
        }

        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            if (flag)
                Cursor.Hide();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            flag = true;
        }

    }
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
        {

            if (flag)
                Cursor.Hide();
            else
                Cursor.Show();
            
            
        }
Comments
Simple but effective!
private void panel1_MouseMove(object sender, MouseEventArgs e)
        {

            if (flag)
                Cursor.Hide();
            else
                Cursor.Show();
            
            
        }

thnks bro,I tried this but it didnt work.:(

This article has been dead for over six months. Start a new discussion instead.