Click here to Skip to main content
15,885,767 members
Articles / Web Development / ASP.NET

Custom Configuration Sections in .NET 2.0

Rate me:
Please Sign up or sign in to vote.
4.53/5 (23 votes)
19 Feb 20068 min read 129K   563   90  
Creating a custom configuration section in .NET 2.0.
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " C�digo generado por el Dise�ador de Windows Forms "

    Public Sub New()
        MyBase.New()

        'El Dise�ador de Windows Forms requiere esta llamada.
        InitializeComponent()

        'Agregar cualquier inicializaci�n despu�s de la llamada a InitializeComponent()

    End Sub

    'Form reemplaza a Dispose para limpiar la lista de componentes.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Requerido por el Dise�ador de Windows Forms
    Private components As System.ComponentModel.IContainer

    'NOTA: el Dise�ador de Windows Forms requiere el siguiente procedimiento
    'Puede modificarse utilizando el Dise�ador de Windows Forms. 
    'No lo modifique con el editor de c�digo.
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents txtOneProperty As System.Windows.Forms.TextBox
    Friend WithEvents txtNumericValue As System.Windows.Forms.TextBox
    Friend WithEvents txtSubElement As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
      Me.Label1 = New System.Windows.Forms.Label
      Me.txtOneProperty = New System.Windows.Forms.TextBox
      Me.txtNumericValue = New System.Windows.Forms.TextBox
      Me.Label2 = New System.Windows.Forms.Label
      Me.txtSubElement = New System.Windows.Forms.TextBox
      Me.Label3 = New System.Windows.Forms.Label
      Me.SuspendLayout()
      '
      'Label1
      '
      Me.Label1.Location = New System.Drawing.Point(24, 8)
      Me.Label1.Name = "Label1"
      Me.Label1.Size = New System.Drawing.Size(88, 16)
      Me.Label1.TabIndex = 0
      Me.Label1.Text = "OneProperty"
      Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
      '
      'txtOneProperty
      '
      Me.txtOneProperty.Location = New System.Drawing.Point(120, 8)
      Me.txtOneProperty.Name = "txtOneProperty"
      Me.txtOneProperty.Size = New System.Drawing.Size(192, 20)
      Me.txtOneProperty.TabIndex = 1
      Me.txtOneProperty.Text = "txtOneProperty"
      '
      'txtNumericValue
      '
      Me.txtNumericValue.Location = New System.Drawing.Point(120, 40)
      Me.txtNumericValue.Name = "txtNumericValue"
      Me.txtNumericValue.Size = New System.Drawing.Size(192, 20)
      Me.txtNumericValue.TabIndex = 3
      Me.txtNumericValue.Text = "txtNumericValue"
      '
      'Label2
      '
      Me.Label2.Location = New System.Drawing.Point(16, 40)
      Me.Label2.Name = "Label2"
      Me.Label2.Size = New System.Drawing.Size(96, 16)
      Me.Label2.TabIndex = 2
      Me.Label2.Text = "NumericValue"
      Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
      '
      'txtSubElement
      '
      Me.txtSubElement.Location = New System.Drawing.Point(120, 72)
      Me.txtSubElement.Name = "txtSubElement"
      Me.txtSubElement.Size = New System.Drawing.Size(192, 20)
      Me.txtSubElement.TabIndex = 5
      Me.txtSubElement.Text = "txtSubElementProp"
      '
      'Label3
      '
      Me.Label3.Location = New System.Drawing.Point(8, 72)
      Me.Label3.Name = "Label3"
      Me.Label3.Size = New System.Drawing.Size(104, 16)
      Me.Label3.TabIndex = 4
      Me.Label3.Text = "Sub-Element Prop"
      Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
      '
      'Form1
      '
      Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
      Me.ClientSize = New System.Drawing.Size(328, 109)
      Me.Controls.Add(Me.txtSubElement)
      Me.Controls.Add(Me.Label3)
      Me.Controls.Add(Me.txtNumericValue)
      Me.Controls.Add(Me.Label2)
      Me.Controls.Add(Me.txtOneProperty)
      Me.Controls.Add(Me.Label1)
      Me.MaximizeBox = False
      Me.Name = "Form1"
      Me.Text = "Configuration in dotNet 1.1 Sample"
      Me.ResumeLayout(False)

   End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With ConfigurationSample.Current
         txtOneProperty.Text = .OneProperty
            txtNumericValue.Text = .OneNumericValue.ToString
            txtSubElement.Text = .OneElement.AnotherProperty
        End With
    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

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
Spain Spain
My first computer was a MSX when I was twelve years old. I liked to develop simple games in Basic (you know... these old sprites...)
My first PC was a 8Mhz with two 5 1/4 floppy disks. The first language that I programed for it was assembler, and I liked to develop graphic demos. About that time Future Crew were my heros.

Now I have a computer engineer degree at Deusto University (Bilbao - Spain) since 1996, and I've been a Microsoft specialist since. Firstly with VB and now with VB.NET. In fact, I have three MCP Certifications (Win-VB6, Win-VB.NET and ASP.NET).

As a senior architect my work involves designing the application architecture for my team. For this work Rational XDE is, I think, the best tool ever made.

I like, development apart, travelling, watching movies, reading, and, of course, playing computer games, mainly MMOPRGs (currently WOW, and Vanguard:SoH as soon as it becomes available).

Comments and Discussions