VB.net Octopus Brother the establishment and use of custom controls

Source: Internet
Author: User

Vb.. NET is to support user-defined controls, this method is particularly useful. Of course, if you want to build a more complex control that requires a lot of knowledge, this article just demonstrates how to build a simple custom control, and how to reference the control in a new project (just like a standard control)

Octopus Brother QQ 3107073263 Group 30981613

㈠ Create a new Windows Forms Control Library named "Custom Control 1"

㈡ drag and drop a standard control into a blank control (here, drag and drop the checkbox and TextBox control, change the background color of the control)


㈢ add code to the control (here is a very simple example, when the checkbox is selected, the Octopus QQ number is displayed, and the custom control is displayed when the check is withdrawn)

Public Class UserControl1    ' octopus brother QQ 3107073263 Group 309816713     ' drag a CheckBox and TextBox control into the control. The custom control inherits both controls when it is dragged into the    Private Sub checkbox1_checkedchanged (ByVal sender as System.Object, ByVal e As System.EventArgs) Handles checkbox1.checkedchanged        if checkbox1.checked then ' octopus Brother 3107073263 ' When CheckBox control is selected            TextBox1.Text = "Octopus brother 3107073263"        Else            TextBox1.Text = "creation and use of custom controls"        End If    End SubEnd Class
㈣ Running the control program

㈤ Close the program and save it. At this point to find the saved path, find the compile-time generated DLL files, we pay attention to the following path, the front may be different, but the last two paths must be the same,
To find the DLL file. Can be copied to any folder, as long as the use of the following can be found on the line

㈥ Create a new Windows Forms blank program (this should be OK). Right-click the mouse in the tool box. Select the Add tab. Name the new tab "Custom Control"

㈦ Right-click under the Custom Control tab and select Select Items ....

㈧ in the dialog box that appears, select the. NET Framework item. Find the bottom navigation button

㈨ Click "Browse button" to find the DLL file generated by the previous double-click Add


Once added, the UserControl1 control will appear in the toolbar (the name may not be the same)


(11) This allows the control to be used as a standard control and dragged directly onto the form. Give it a try.


(12) Run to see


All right, here we go. This article is about a method, of course, more complex way there are many, want to make the control more practical and users need to be more self-pondering. Welcome reprint, note the source!





VB.net the creation and use of custom controls for Octopus brother

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.