Creating controls

Posted on 2012-09-06
Last Modified: 2012-10-10
I frequently create forms for my applications.  The forms almost always include a Clear and a Close button, which always do the same thing.  There is also a Process button and a Delete button, which always look the same, but the code attached to them would differ slightly from application to application.

I'm sure there is a way that I can put these controls into a library somewhere and just pull them from the library to a new form without having to create them each time.  But I can't figure out how to do that.  Is there a straightforward way to create and use a Controls Library for this purpose?
Question by:thoecherl
    LVL 85

    Accepted Solution

    You can create a UserControl, or derive a Class from Button, to make your custom Control.  Save and compile it.

    Now you can right click the ToolBox, select "Choose items", then hit Browse and navigate to the assembly containing your control.

    Author Comment

    Thanks Idle_Mind.  But I'm afraid I still need a bit of help.  I am not a total novice at Studio.  I have been using both for about 2 years and I have developed several projects for clients.  But there is still a lot I don't know.  I don't know how to create a UserControl nor how to derive a Class from a Button, for example.

    I know it is basic stuff, but can you direct me to a link somewhere that can give me the steps I should take to do this?  Also, after I get the custom control created and, later I open Visual Studio for another project, how do I reference the control so that when I right click the tool box it will be on the list?

    LVL 85

    Assisted Solution

    by:Mike Tomlinson
    For a UserControl, just click on:

        Project --> Add User Control

    For a Derived Button, you can do Project --> Add Class, then replace the code with something like:

        Public Class MyButton
            Inherits Button

        End Class

    Author Comment

    We will be testing next week, will respond then.

    Author Closing Comment

    Thank you.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    755 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

    19 Experts available now in Live!

    Get 1:1 Help Now