Click here to Skip to main content
Licence 
First Posted 11 Aug 2004
Views 47,314
Bookmarked 41 times

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

By | 11 Aug 2004 | Article
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

About the Author

Francesco Smelzo

Web Developer

Italy Italy

Member

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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 5 Pinmemberaaroncampf19:01 31 Dec '10  
Generalhehehehe..... Pinmembernoor_adilah18:15 11 Feb '07  
GeneralGreat PinmemberaKriss16:45 6 Feb '05  
GeneralSweet PinmemberAaron Eldreth6:24 12 Aug '04  
GeneralRe: Sweet PinmemberFrancesco Smelzo6:58 12 Aug '04  
GeneralRe: Sweet PinmemberAaron Eldreth8:45 12 Aug '04  

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

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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 12 Aug 2004
Article Copyright 2004 by Francesco Smelzo
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid