[Beginner vb.net] How to control a control by its name

Source: Internet
Author: User
Tags compact visibility
Beginner | controls | control Imports System.Reflection

Dim I as Integer
Dim Namestr as String
For i = 0 to Dataset_system. Tables ("Company"). Columns.count-1
Namestr = ""
Namestr = "Txt_company_" & Dataset_system. Tables ("Company"). Columns.item (i). Caption
Dim T as Type = Me.GetType
Dim f as FieldInfo = T.getfield ("_" & Namestr, BindingFlags.NonPublic or bindingflags.instance or bindingflags.public)
If Dataset_system. Tables ("Company"). Columns.item (i). Caption = "International Society" Then
Dim mycontrol as CheckBox = CType (F.getvalue (Me), CheckBox)
mycontrol.enabled = Chg
Else
Dim mycontrol as TextBox = CType (F.getvalue (Me), TextBox)
mycontrol.enabled = Chg
End If
Next

---------------------------------------------------------------------------------
FieldInfo Overview

Public properties
Attributes
Supported by the. NET Compact Framework.
Gets the attributes associated with this field.
DeclaringType (inherited from MemberInfo)
Supported by the. NET Compact Framework.
Gets the class that declares the member.
Fieldhandle
Supported by the. NET Compact Framework.
Gets the RuntimeFieldHandle, which is the handle to the internal metadata representation of the field.
FieldType
Supported by the. NET Compact Framework.
Gets the type of this Field object.
isassembly
Supported by the. NET Compact Framework.
Gets a value indicating whether the field has assembly-level visibility.
Isfamily
Supported by the. NET Compact Framework.
Gets a value indicating whether this field has family-level visibility.
isfamilyandassembly
Supported by the. NET Compact Framework.
Gets a value indicating whether this field has familyandassembly level visibility.
isfamilyorassembly
Supported by the. NET Compact Framework.
Gets a value indicating whether this field has familyorassembly level visibility.
Isinitonly
Supported by the. NET Compact Framework.
Gets a value indicating whether this field can be set only in the body of the constructor.
Isliteral
Supported by the. NET Compact Framework.
Gets a value indicating whether the value is written at compile time and cannot be changed.
Isnotserialized
Supported by the. NET Compact Framework.
Gets a value indicating whether this field has a notserialized attribute.
Ispinvokeimpl
Supported by the. NET Compact Framework.
Gets a value indicating whether the corresponding PinvokeImpl attribute is set in FieldAttributes.
IsPrivate
Supported by the. NET Compact Framework.
Gets a value indicating whether this field is a private field.
IsPublic
Supported by the. NET Compact Framework.
Gets a value indicating whether this field is a public field.
Isspecialname
Supported by the. NET Compact Framework.
Gets a value indicating whether the corresponding SpecialName attribute is set in the FieldAttributes enumerator.
IsStatic
Supported by the. NET Compact Framework.
Gets a value indicating whether this field is a static field.
MemberType
Supported by the. NET Compact Framework.
has been overridden. Gets the Type of the property that this FieldInfo object reflects. Retrieves a value indicating that the member is a field.
Name (inherited from MemberInfo)
Supported by the. NET Compact Framework.
Gets the name of this member.
ReflectedType (inherited from MemberInfo)
Supported by the. NET Compact Framework.
Gets the class object that is used to get this instance of the MemberInfo.




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.