Custom dialog with custom class : Custom Dialog « GUI « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » GUI » Custom Dialog 
14.69.7.Custom dialog with custom class
Custom dialog with custom class
Imports System.Windows.Forms

public class CustomDialogWithCustomClass
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is NothingThen
                components.Dispose()
            End If
        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.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(10488)
        Me.Button1.Name = "Button1"
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "Button1"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(513)
        Me.ClientSize = New System.Drawing.Size(292266)
        Me.Controls.Add(Me.Button1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Button1_Click_
            ByVal sender As System.Object, _
            ByVal e As System.EventArgs_
            Handles Button1.Click

        Dim addr As New address
        Dim address As New addressDialog

        Dim Street As String = "124 "
        Dim City As String = "R"
        Dim Country As String = "VA"
        Dim PostalCode As String = "11111"

        addr.Street = Street
        addr.City = City
        addr.Country = Country
        addr.PostalCode = PostalCode

        address.Address = addr
        If address.ShowDialog = DialogResult.OK Then
            addr = address.Address
        End If
    End Sub
End Class

Public Class address
    Dim m_Street As String
    Dim m_City As String
    Dim m_PostalCode As String
    Dim m_Country As String

    Public Property Street() As String
        Get
            Return m_Street
        End Get
        Set(ByVal Value As String)
            m_Street = Value
        End Set
    End Property

    Public Property City() As String
        Get
            Return m_City
        End Get
        Set(ByVal Value As String)
            m_City = Value
        End Set
    End Property

    Public Property PostalCode() As String
        Get
            Return m_PostalCode
        End Get
        Set(ByVal Value As String)
            m_PostalCode = Value
        End Set
    End Property

    Public Property Country() As String
        Get
            Return m_Country
        End Get
        Set(ByVal Value As String)
            m_Country = Value
        End Set
    End Property


End Class

Public Class addressDialog
    Inherits System.Windows.Forms.Form
    Public Property Address() As address
        Get
            Dim newAddress As New address
            newAddress.City = txtCity.Text
            newAddress.Country = txtCountry.Text
            newAddress.PostalCode = txtPostalCode.Text
            newAddress.Street = txtStreet.Text
            Return newAddress
        End Get
        Set(ByVal Value As Address)
            txtCity.Text = Value.City
            txtCountry.Text = Value.Country
            txtPostalCode.Text = Value.PostalCode
            txtStreet.Text = Value.Street
        End Set
    End Property

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is NothingThen
                components.Dispose()
            End If
        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.
    Friend WithEvents saveAddress As System.Windows.Forms.Button
    Friend WithEvents cancelAddress As System.Windows.Forms.Button
    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 Label4 As System.Windows.Forms.Label
    Friend WithEvents txtStreet As System.Windows.Forms.TextBox
    Friend WithEvents txtCity As System.Windows.Forms.TextBox
    Friend WithEvents txtPostalCode As System.Windows.Forms.TextBox
    Friend WithEvents txtCountry As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
        Me.saveAddress = New System.Windows.Forms.Button
        Me.cancelAddress = New System.Windows.Forms.Button
        Me.txtStreet = New System.Windows.Forms.TextBox
        Me.txtCity = New System.Windows.Forms.TextBox
        Me.txtPostalCode = New System.Windows.Forms.TextBox
        Me.txtCountry = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'saveAddress
        '
        Me.saveAddress.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.saveAddress.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.saveAddress.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.saveAddress.Location = New System.Drawing.Point(128120)
        Me.saveAddress.Name = "saveAddress"
        Me.saveAddress.TabIndex = 0
        Me.saveAddress.Text = "OK"
        '
        'cancelAddress
        '
        Me.cancelAddress.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.cancelAddress.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.cancelAddress.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.cancelAddress.Location = New System.Drawing.Point(208120)
        Me.cancelAddress.Name = "cancelAddress"
        Me.cancelAddress.TabIndex = 1
        Me.cancelAddress.Text = "Cancel"
        '
        'txtStreet
        '
        Me.txtStreet.Location = New System.Drawing.Point(8016)
        Me.txtStreet.Name = "txtStreet"
        Me.txtStreet.Size = New System.Drawing.Size(20020)
        Me.txtStreet.TabIndex = 2
        Me.txtStreet.Text = "txtStreet"
        '
        'txtCity
        '
        Me.txtCity.Location = New System.Drawing.Point(8040)
        Me.txtCity.Name = "txtCity"
        Me.txtCity.Size = New System.Drawing.Size(20020)
        Me.txtCity.TabIndex = 3
        Me.txtCity.Text = "txtCity"
        '
        'txtPostalCode
        '
        Me.txtPostalCode.Location = New System.Drawing.Point(8064)
        Me.txtPostalCode.Name = "txtPostalCode"
        Me.txtPostalCode.Size = New System.Drawing.Size(11220)
        Me.txtPostalCode.TabIndex = 4
        Me.txtPostalCode.Text = "txtPostalCode"
        '
        'txtCountry
        '
        Me.txtCountry.Location = New System.Drawing.Point(8088)
        Me.txtCountry.Name = "txtCountry"
        Me.txtCountry.Size = New System.Drawing.Size(20020)
        Me.txtCountry.TabIndex = 5
        Me.txtCountry.Text = "txtCountry"
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(3918)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(3816)
        Me.Label1.TabIndex = 6
        Me.Label1.Text = "Street:"
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(5042)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(2716)
        Me.Label2.TabIndex = 7
        Me.Label2.Text = "City:"
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.Location = New System.Drawing.Point(866)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(6916)
        Me.Label3.TabIndex = 8
        Me.Label3.Text = "Postal Code:"
        '
        'Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.Location = New System.Drawing.Point(3390)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(4416)
        Me.Label4.TabIndex = 9
        Me.Label4.Text = "Country"
        '
        'addressDialog
        '
        Me.AcceptButton = Me.saveAddress
        Me.AutoScaleBaseSize = New System.Drawing.Size(513)
        Me.CancelButton = Me.cancelAddress
        Me.ClientSize = New System.Drawing.Size(292152)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.txtCountry)
        Me.Controls.Add(Me.txtPostalCode)
        Me.Controls.Add(Me.txtCity)
        Me.Controls.Add(Me.txtStreet)
        Me.Controls.Add(Me.cancelAddress)
        Me.Controls.Add(Me.saveAddress)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "addressDialog"
        Me.Text = "Address Dialog"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub saveAddress_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles saveAddress.Click
        Me.Close()
    End Sub

    Private Sub cancelAddress_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles cancelAddress.Click
        Me.Close()
    End Sub
End Class
14.69.Custom Dialog
14.69.1.Create Dialog from FormCreate Dialog from Form
14.69.2.User defined DialogUser defined Dialog
14.69.3.Get Custom dialog returning valueGet Custom dialog returning value
14.69.4.Login DialogLogin Dialog
14.69.5.About DialogAbout Dialog
14.69.6.Dialog apply methodDialog apply method
14.69.7.Custom dialog with custom classCustom dialog with custom class
14.69.8.Dialog with propertiesDialog with properties
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.