Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Automate code-writing in VB.NET control's development

0.00/5 (No votes)
11 Aug 2004 1  
Utility for automating code writing for VB.NET control's developers

Introduction

When you develop a new control in .NET Framework often reuse standard controls as textboxes , buttons etc�

Commonly we have to replicate, at control level , properties of a child control and is a very tedious work to hand-write the code for all hosted properties.

Details

Look, for example at this control

sample control

Probably the Control should have properties similar to child controls

In this case, for example, Control's Text property should be textbox property

Well so you must manually rewrite all properties statements in this way:

Public Property BoxText() As String
        Get
            Return Me.TextBox1.Text
        End Get
        Set(ByVal Value As String)
            Me.TextBox1.Text = Value
        End Set
 End Property

That is a very tedious work, considering that much properties as similars (like Font, Background and so on)

Class Inspector

Class Inspector can spy and recreate properties declarations of controls, components enums and other classes containeds in an assembly.

You can load any .NET assembly and in the left treeView will be loaded all assembly referenced in it (if you don't specify an assembly with menu item "File/Get references from an assembly" will be loaded the program assembly itself).

You can now navigate in tree nodes to class/enum that you want inspect and, by clicking on this, in right text panel will be appears VB code for properties declararations of inspected class.

The code can be browsed,copied and saved. You can also define a Prefix for properties names, so if you define i.e. Btn the Text property declaration appear as

'Text

'

Private _BtnText as System.String
<Description("The text contained in the control.")> _
Public  Property BtnText as System.String
   Get
       return _BtnText
   End Get
   Set (Value as System.String)
       _BtnText=Value
   End Set
End Property

You can, moreover, define a language different from default (English) by setting relative combobox

If i.e. I set language to Italian (and if my .NET framework distribution supports this language) the precendent property declaration will appears as

'Text

'

Private _BtnText as System.String
<Description("Il testo contenuto nel controllo.")> _
Public  Property BtnText as System.String
   Get
       return _BtnText
   End Get
   Set (Value as System.String)
       _BtnText=Value
   End Set
End Property

That is Description attributes will be translate in the selected language.

Remarks

The source project was written with Visual Studio 2003 and the program was tested with .NET framework v.1.1

In my site is also avaible a setup package

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here