Winform component development: Construct the imagebutton Control

Source: Internet
Author: User

The button and picturebox provided by. NET are difficult to control when performing special effects. Besides adjusting attributes, you must also writeCodeIs it very troublesome. If your Development Team asks you to construct a button component to replace the button that comes with. netArticleIt will guide you to achieve this requirement.
Let's take a look at the iamgebutton features we will develop:
1. The Properties window is supported.
2. provides four attributes: buttontext, buttonimage, mouseoverimage, and mouseclickimage to implement the special effect.
Special effects: I only need to set the above four attributes to achieve the dynamic effect of imagebutton without writing a line of code. By default, the display image of imagebutton is set by the attribute of buttonimage. When you move the mouse over this button, it will produce a dynamic effect and switch to another image. This is a function of the mouseoverimage attribute. When you click the button, it will switch to another image to achieve dynamic effects. This is implemented by the mouseclickimage attribute.
3. All the above four attributes are placed in the "important attributes" item in the attribute window.
4. supports common button functions.
This button can speed up the progress of your project and never take the monotonous button provided for. Net to control its style.
Component: Lt. winform. imagebutton. dll
Component Demo project: testimagebutton.rar
Demo image:

When you move the cursor over the logon or exit button, the background effect becomes:

When you click the "Log on" or "exit" button, the background effect changes:

When the mouse leaves the logon or exit button, the background effect will become the default image:

Implementation of imagebutton:
Imageboutton is constructed by inheriting the usercontrol class and combining the lable and picturebox controls. 5 mouse events of lable and picturebox are implemented, and click events are rewritten. One difficulty is how to display click events and lable in the middle. The implementation of the four attributes is not very difficult, but it is indeed difficult to implement the image switching with pictuerbox.

Note: The imagebutton component has been used in several projects. Please feel free to use and expand it.
Source code: Lt. winform. imagebutton

If you have read the source code and have any suggestions, please submit them to me. Thank you.

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.