When the button is clicked, the effect of the button being pressed is displayed.

Source: Internet
Author: User

In actual projects, in order to provide a better user experience, when you click a button, you must be able to display the status when the button is pressed, giving you a dynamic feeling.

In fact, this is easier to implement in the program. You only need to add a button background image. A status chart is displayed when the button is not pressed or popped up.

Display another status chart.

The specific implementation is not only to write the button click method, but also to write the button's mouseup and mousedown events.

The sample code is as follows:

/// <Summary>
/// Online order screen refresh button (when the status is popped up)
/// </Summary>
Private string strpurchaserefreshbtnimg = application. startuppath + "\ resources \" + "btnrefresh.png ";
/// <Summary>
/// Online order screen refresh button (when pressing down)
/// </Summary>
Private string strpurchaserefreshbtndownimg = application. startuppath + "\ resources \" + "btnrefresh_down.png ";

/// <Summary>
/// When refresh is pressed
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Private void btnrefresh_mousedown (Object sender, mouseeventargs E)
{
Btnrefresh. backgroundimage = image. fromfile (strpurchaserefreshbtndownimg );
}
/// <Summary>
/// The refresh button is released.
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Private void btnrefresh_mouseup (Object sender, mouseeventargs E)
{
Btnrefresh. backgroundimage = image. fromfile (strpurchaserefreshbtnimg );
}

 

/// <Summary>
/// Refresh the page
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Private void btnrefresh_click (Object sender, eventargs E)
{
// Do something...

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.