Exforsys

VB.NET 2005

  1. VB.NET 2005 Free Training
  2. The .NET Framework Architecture Part 1
  3. The .NET Framework Architecture Part 2
  4. Application Class and Message Class
  5. Implementing Class Library Object
  6. Visual Studio.NET Namespaces
  7. .NET Assemblies
  8. Differences between VB.NET 1.0 and VB.NET 2.0
  9. Introducing VB.NET Windows Forms
  10. Visual Studio Windows Forms Designer
  11. Exploring the Forms Designer generated code
  12. Setting and Adding Properties to Windows Form
  13. Implementing Inheritance
  14. Event Handling In Visual Basic .NET
  15. Building Graphical Interface elements
  16. .NET Common Windows Forms Controls Part 1
  17. .NET Common Windows Forms Controls Part 2
  18. Common Controls and Handling Control Events
  19. DomainUpDown and NumericUpDown Controls
  20. Dialog Boxes in Visual Basic .NET
  21. Visual Studio Adding Controls to Windows Form
  22. VB.NET Validation Controls
  23. Working with Menu Controls
  24. VB.NET MDI Applications
  25. .NET Exceptions
  26. VB.NET Creating and Managing Components Part 1
  27. VB.NET Creating and Managing Components Part 2
  28. Simple Data Binding
  29. .NET Complex Data Binding
  30. .NET Data Form Wizard
  31. Data Manipulation with ADO.NET
  32. SQL Server Stored Procedures
  33. SQL Server Ad Hoc Queries
  34. Finding and Sorting Data in DataSets
  35. ADO.NET Object Model
  36. Working with DataSets
  37. Using XML Data
  38. Working with File System in .NET
  39. Creating Web Service
  40. Instantiating - Invoking Web Services, Creating Proxy Classes with WSDL
  41. Web Reference and Web Services
  42. Web Services - SOAP, WSDL, Disco and UDDI
  43. Web Application Testing in VB.NET 2005
  44. Web Application Tracing and Debugging
  45. Working with Legacy Code and COM Components
  46. ActiveX Controls and Legacy Code
  47. Windows Application Testing
  48. VB.NET Windows Application Testing
  49. Tracing VB.NET Windows Application
  50. Debugging Windows Applications In Visual Studio.NET 2005
  51. Deploying Windows Applications In Visual Studio.NET 2005
  52. Customizing Setup Project in Visual Studio.NET 2005
  53. Shared Assembly
  54. Microsoft .NET Creating Installation Components
  55. The Registry Editor in Visual Studio.NET 2005
  56. The File Types Editor

Ads


Home arrow Technical Training arrow VB.NET 2005

Exploring the Forms Designer generated code

Author : Exforsys Inc.     Published on: 7th Jun 2005    |   Last Updated on: 3rd Jan 2009

VB.NET 2005 Free Training

Exploring the Forms Designer generated code

As you create a new project in the Visual Basic, the IDE generally automatically adds lots of lines of code on its own. Visual Basic 2005 comes with an option to skip over this behavior of the Visual Basic IDE. The default option comes with this behavior enabled.

Ads

These codes are introduced with an aim that the user can continue to use the form without bothering about write codes to instantiate the form with a function new() and also the code includes the declaration and instantiation of all the controls that have been dragged and dropped on to the form. As a developer you may need to add controls like text boxes, grid controls, database controls and also need to bind data to some control at design time.

Much of these activities can be done at design time and visually without adding any line of code. The Visual Basic IDE is equipped with inbuilt facility that generates codes for these features. The more interesting part is not just that. You can actually add functionality to the form by adding codes to these functions like new() which is the first function to be executed and can be used to perform additional tasks at the start time of the application or even before the form load takes place.

This code is stored in a new file Form1.Designer.vb. Let us take a closer look at this now. These codes that we are going to see have been taken from one of the demos of this tutorial.

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated() > _

Partial Public Class Form1

    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.

    <System.Diagnostics.DebuggerNonUserCode()> _

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

        If disposing AndAlso components IsNot Nothing Then

            components.Dispose()

        End If

        MyBase.Dispose(disposing)

    End Sub 

    'Required by the Windows Form Designer

    Private components As System.ComponentModel.IContainer 

    'NOTE: The following procedure is required by the Windows Form Designer

    'It can be modified using the Windows Form Designer. 

    'Do not modify it using the code editor.

    <System.Diagnostics.DebuggerStepThrough()> _

    Private Sub InitializeComponent()

        Me.Button1 = New System.Windows.Forms.Button

        Me.Button2 = New System.Windows.Forms.Button

        Me.Button3 = New System.Windows.Forms.Button

        Me.Button4 = New System.Windows.Forms.Button

        Me.Button5 = New System.Windows.Forms.Button

        Me.Button6 = New System.Windows.Forms.Button

        Me.Button7 = New System.Windows.Forms.Button

        Me.SuspendLayout()

        'Button1

        Me.Button1.Location = New System.Drawing.Point(13, 238)

        Me.Button1.Name = "Button1"

        Me.Button1.Size = New System.Drawing.Size(75, 23)

        Me.Button1.TabIndex = 0

        Me.Button1.Text = "Line"

        'Button2

        Me.Button2.Location = New System.Drawing.Point(98, 238)

        Me.Button2.Name = "Button2"

        Me.Button2.Size = New System.Drawing.Size(75, 23)

        Me.Button2.TabIndex = 1

        Me.Button2.Text = "Ellipse"

         'Form1

        '

        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)

        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font

        Me.ClientSize = New System.Drawing.Size(612, 273)

        Me.Controls.Add(Me.Button2)

        Me.Controls.Add(Me.Button1)

        Me.Name = "Form1"

        Me.Text = "Painting Shapes and Fill Objects"

        Me.ResumeLayout(False) 

    End Sub

    Friend WithEvents Button1 As System.Windows.Forms.Button

    Friend WithEvents Button2 As System.Windows.Forms.Button     

End Class

Definitions

InitializeComponent: This method helps to persist the property values that you have set in the Designer.

Public Sub New():The class constructor. You can put include some code that you want at the start up. However the best location for this code is the forms Load event.

Security in Windows Form:

The .NET Framework provides a superior security features in the application by introducing new features. The code access security allows you to permit varied degrees or trust to the code depending on where the code originates and also other factors that define the identity of the code. Security permissions are implemented to ensure security. Code can request the permissions it needs.

The .NET Framework security system determines whether such requests are honored. Requests are honored after verifying the code's evidence and only relevant requests are granted those permissions. The permission given to the code never exceeds the current security settings. However, code will be granted less permission based upon a request.

The identity of the code forms the basis for granting the runtime permissions, also the level of trust the code is granted is determined by the security policy.

Code can demand that its callers have specific permissions. If you place a demand for certain permission on your code, all code that uses your code must have that permission to run.

There are three kinds of permissions, each with a specific purpose

Ads

Code access permissions, which represent access to a protected resource or the ability to perform a protected operation.

Identity permissions, which indicate that code has credentials that support a particular kind of identity.

Role-based security permissions, which provide a mechanism for discovering whether a user has a particular identity or is a member of a specified role. Thus a very robust and well managed security is provided in the .NET Framework.



 
This tutorial is part of a VB.NET 2005 tutorial series. Read it from the beginning and learn yourself.

VB.NET 2005

  1. VB.NET 2005 Free Training
  2. The .NET Framework Architecture Part 1
  3. The .NET Framework Architecture Part 2
  4. Application Class and Message Class
  5. Implementing Class Library Object
  6. Visual Studio.NET Namespaces
  7. .NET Assemblies
  8. Differences between VB.NET 1.0 and VB.NET 2.0
  9. Introducing VB.NET Windows Forms
  10. Visual Studio Windows Forms Designer
  11. Exploring the Forms Designer generated code
  12. Setting and Adding Properties to Windows Form
  13. Implementing Inheritance
  14. Event Handling In Visual Basic .NET
  15. Building Graphical Interface elements
  16. .NET Common Windows Forms Controls Part 1
  17. .NET Common Windows Forms Controls Part 2
  18. Common Controls and Handling Control Events
  19. DomainUpDown and NumericUpDown Controls
  20. Dialog Boxes in Visual Basic .NET
  21. Visual Studio Adding Controls to Windows Form
  22. VB.NET Validation Controls
  23. Working with Menu Controls
  24. VB.NET MDI Applications
  25. .NET Exceptions
  26. VB.NET Creating and Managing Components Part 1
  27. VB.NET Creating and Managing Components Part 2
  28. Simple Data Binding
  29. .NET Complex Data Binding
  30. .NET Data Form Wizard
  31. Data Manipulation with ADO.NET
  32. SQL Server Stored Procedures
  33. SQL Server Ad Hoc Queries
  34. Finding and Sorting Data in DataSets
  35. ADO.NET Object Model
  36. Working with DataSets
  37. Using XML Data
  38. Working with File System in .NET
  39. Creating Web Service
  40. Instantiating - Invoking Web Services, Creating Proxy Classes with WSDL
  41. Web Reference and Web Services
  42. Web Services - SOAP, WSDL, Disco and UDDI
  43. Web Application Testing in VB.NET 2005
  44. Web Application Tracing and Debugging
  45. Working with Legacy Code and COM Components
  46. ActiveX Controls and Legacy Code
  47. Windows Application Testing
  48. VB.NET Windows Application Testing
  49. Tracing VB.NET Windows Application
  50. Debugging Windows Applications In Visual Studio.NET 2005
  51. Deploying Windows Applications In Visual Studio.NET 2005
  52. Customizing Setup Project in Visual Studio.NET 2005
  53. Shared Assembly
  54. Microsoft .NET Creating Installation Components
  55. The Registry Editor in Visual Studio.NET 2005
  56. The File Types Editor
 

Comments

 

Share


Connect

Exforsys e-Newsletter

Enhance Technical and Soft Skills every week, get our Job Interview Questions and Answers eBook free when you subscribe.

Subscribe and Get Free Bonus PDF Book

eBook

Subscribe