VB.net the contents of the control to be empty (controls Class) __.net

Source: Internet
Author: User
Tags windows visual

In the usual knocking system, did you ever encounter the need to let the TextBox control or other controls display the contents of empty, before the direct method is directly equal to null value, if such a control has many, all need null value, it is necessary to set its value is empty, it is obviously a stupid way, there is no better way to let it, The answer is yes.

In the development. When netwindows an application, we all use controls that System.Windows.Forms namespaces. namespaces to encapsulate the controls we use into classes, and when we use them, we instantiate these classes as the controls we need. These are the molds, and the molds are placed in a place called control. The control class is important because it is the parent class for Windows visual components. The control class implements the most basic functionality required for a class that displays information to the user. It handles the input that the user makes through the keyboard and the pointing device. It also handles message routing and security. Although it does not implement drawing, it defines the bounds of the control (its position and size). It provides a window handle (hWnd).

We can also develop new controls based on existing controls while using the controls that Microsoft provides to us. When developing custom controls, we can use existing controls or extend the control or UserControl classes. Extending the control or UserControl class means we need to overwrite the OnPaint method and draw our own graphical user interface. We can study how to do this.

Knowing the basics, let's get to the point--how to make the contents of the control empty

My Code is

Dim C as Control             ' defines a control class
for every C in Me.GroupBox1.Controls    ' Loop GroupBox1 the content of Controls in a form
    LCase (TypeName (c)) = "TextBox" Then  ' If the class name is textbox
        c.text = "                       ' His value is null end
    if
 Next
The current understanding of control only stays on the surface, hoping to deepen his understanding through continuous learning.


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.