Search code examples
c#winformscursor

How to make a customize cursor when you click a button


How can i customize when clicking a button that will project a waitcursor

enter image description here

like when you hover your mouse, for example in the back button , it will be default cursor or the hand thing and when i click it will display like this

enter image description here

thank you in advance


Solution

  • i manage to answer my question

    private void btnLOGIN_Click(object sender, EventArgs e)
        { 
            try
            {
    
                Cursor.Current = Cursors.WaitCursor;
                Application.DoEvents();
                System.Threading.Thread.Sleep(500);//set time to load
    
                if (txtUser.Text == "admin" && txtPass.Text == "")
                {
                    this.Hide();
                    MENU ss = new MENU();
                    MessageBox.Show("Welcome to CornerFlag's Product Monitoring System!", "Login Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ss.Show();
                }
                else
                {
                    MessageBox.Show("Invalid Input , Try Again ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtUser.Clear();
                    txtPass.Clear();
                };
    
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
    
        }