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...
}