Click here to Skip to main content
15,881,687 members
Articles / Programming Languages / Visual Basic
Article

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

Rate me:
Please Sign up or sign in to vote.
4.89/5 (11 votes)
11 Aug 20042 min read 60.4K   1.1K   41   6
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:

VB.NET
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

VB.NET
'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

VB.NET
'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


Written By
Web Developer
Italy Italy
Francesco Smelzo is a free-lance developer that live and work in Italy,he is specialized on microsoft platform development and in web projects.

He is specially skilled on VB.NET, XML,XSL and most of web scripting languages.

Comments and Discussions

 
GeneralMy vote of 5 Pin
aaroncampf31-Dec-10 19:01
aaroncampf31-Dec-10 19:01 
Generalhehehehe..... Pin
noor_adilah11-Feb-07 18:15
noor_adilah11-Feb-07 18:15 
GeneralGreat Pin
Member 7648536-Feb-05 16:45
Member 7648536-Feb-05 16:45 
GeneralSweet Pin
Aaron Eldreth12-Aug-04 6:24
Aaron Eldreth12-Aug-04 6:24 
GeneralRe: Sweet Pin
Francesco Smelzo12-Aug-04 6:58
Francesco Smelzo12-Aug-04 6:58 
GeneralRe: Sweet Pin
Aaron Eldreth12-Aug-04 8:45
Aaron Eldreth12-Aug-04 8:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.