Change the default button image - visual studio 2010

Posted on 2012-09-11
Last Modified: 2012-09-11
I am working on a project that has multiple forms with probably close to 100 total buttons.  Right now, those buttons are actually pictureboxes that I create mouseenter, mouseleave, and click events to act like buttons.

Occasionally, I want to change the appearance of the program, but I then have to individually change each picturebox image to change the appearance of the button.  That means changing the mouseenter and mouseleave images for every single button.

Is there anyway that I can change the default button image and it's mouseover image so that I can simply change the one button and it will apply to all buttons in my program?  Something that would allow me to also enter different text onto each button, but maintain the same image.
Question by:lostinthegame
    LVL 12

    Accepted Solution

    I think you'll have to create a custom/extended control and use that in place of the standard button/picture box.

    Author Closing Comment

    Awesome!  Got it working.  Here's what I did:

    1) created a new Windows Form Control Project
    2) changed the designer.vb to inherit button instead of control
    3) fixed the errors that popped up
    4) imported my mouseover and mouseup images
    5) set my mouseup image as the control background image
    6) added the mouseenter and mouseleave events to change the image
    7) built the project and then closed it
    8) opened my windows form project, right clicked the toolbar, and picked "choose items"
    9) opened the .dll from my control project's bin folder
    10) dragged the new button onto my windows form

    I tested it out, and all I have to do now is change the image in my control projects resource file and then rebuild it to change all of the buttons in my windows form project.

    Wish I knew this before.  I've probably spent 50 hours redesigning each button multiple times...

    Thanks for the help.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now