| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 
 |  
Public Class Form1
    Inherits System.Windows.Forms.Form
 
#Region " Code généré par le Concepteur Windows Form "
 
    Public Sub New()
        MyBase.New()
 
        'Cet appel est requis par le Concepteur Windows Form.
        InitializeComponent()
 
        'Ajoutez une initialisation quelconque après l'appel InitializeComponent()
 
    End Sub
 
    'La méthode substituée Dispose du formulaire pour nettoyer la liste des composants.
    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
 
    'Requis par le Concepteur Windows Form
    Private components As System.ComponentModel.IContainer
 
    'REMARQUE : la procédure suivante est requise par le Concepteur Windows Form
    'Elle peut être modifiée en utilisant le Concepteur Windows Form.  
    'Ne la modifiez pas en utilisant l'éditeur de code.
    Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.ComboBox1 = New System.Windows.Forms.ComboBox
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.TextBox2 = New System.Windows.Forms.TextBox
        Me.TextBox3 = New System.Windows.Forms.TextBox
        Me.SuspendLayout()
        '
        'ComboBox1
        '
        Me.ComboBox1.Location = New System.Drawing.Point(5, 5)
        Me.ComboBox1.Name = "ComboBox1"
        Me.ComboBox1.Size = New System.Drawing.Size(282, 21)
        Me.ComboBox1.TabIndex = 0
        Me.ComboBox1.Text = "ComboBox1"
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(5, 31)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(282, 20)
        Me.TextBox1.TabIndex = 1
        Me.TextBox1.Text = "TextBox1"
        '
        'TextBox2
        '
        Me.TextBox2.Location = New System.Drawing.Point(5, 56)
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.Size = New System.Drawing.Size(282, 20)
        Me.TextBox2.TabIndex = 2
        Me.TextBox2.Text = "TextBox2"
        '
        'TextBox3
        '
        Me.TextBox3.Location = New System.Drawing.Point(5, 80)
        Me.TextBox3.Name = "TextBox3"
        Me.TextBox3.Size = New System.Drawing.Size(282, 20)
        Me.TextBox3.TabIndex = 3
        Me.TextBox3.Text = "TextBox3"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Controls.Add(Me.TextBox3)
        Me.Controls.Add(Me.TextBox2)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.ComboBox1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)
 
    End Sub
 
#End Region
 
    Protected Structure Divisions
        Private divName As String
        Private divId As Integer
        Private divParam As String
 
        Public Sub New(ByVal name As String, ByVal id As Integer, ByVal param As String)
            divName = name
            divId = id
            divParam = param
        End Sub
 
        Public ReadOnly Property getName() As String
            Get
                Return divName
            End Get
        End Property
 
        Public ReadOnly Property getId() As Integer
            Get
                Return divId
            End Get
        End Property
 
        Public ReadOnly Property getParam() As String
            Get
                Return divParam
            End Get
        End Property
    End Structure
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim myDivisions As New ArrayList
        With myDivisions
            .Add(New Divisions("NORD", 1, "nord"))
            .Add(New Divisions("SUD", 2, "sud"))
            .Add(New Divisions("EST", 3, "est"))
            .Add(New Divisions("OUEST", 4, "ouest"))
            .Add(New Divisions("CENTRE", 5, "centre"))
        End With
 
        ' On vide le combobox
        ComboBox1.Items.Clear()
 
        ' On arrête l'affichage du composant pour une question de vitesse
        ComboBox1.SuspendLayout()
        ' On commence à remplir le composant sans mise à jour immédiate
        ComboBox1.BeginUpdate()
 
        ' On remplit le composant
        With ComboBox1
            .DataSource = myDivisions
            .DisplayMember = "getName"
            .ValueMember = "getId"
        End With
 
        ' On signale que le composant est remplit
        ComboBox1.EndUpdate()
        ' On redémarre l'affichage du composant
        ComboBox1.ResumeLayout()
 
        ' On sélection automatique la première valeur
        ComboBox1.SelectedItem = ComboBox1.Items(0)
    End Sub
 
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        TextBox1.Text = CType(ComboBox1.SelectedItem, Divisions).getName
        TextBox2.Text = CStr(CType(ComboBox1.SelectedItem, Divisions).getId)
        TextBox3.Text = CType(ComboBox1.SelectedItem, Divisions).getParam
    End Sub
End Class |