1 2 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
|
'le combo est popule comme suit à partir du designer:
'1er Trimestre 2012
'2er Trimestre 2012
'3er Trimestre 2012
'4er Trimestre 2012
Public Class Form1
Public Sub New()
' Cet appel est requis par le Concepteur Windows Form.
InitializeComponent()
' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
Me.ComboBox1.SelectedIndex = 0
Me.Label1.Text = Me.ComboBox1.SelectedItem.ToString
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.TextBox1.Text = "Hola!"
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim currentPos As Integer = ComboBox1.SelectedIndex
If Me.TextBox1.Text <> String.Empty Then
Me.ComboBox1.Items.Insert(ComboBox1.SelectedIndex, Me.TextBox1.Text)
Me.ComboBox1.Items.RemoveAt(ComboBox1.SelectedIndex)
Me.TextBox1.Clear()
End If
'position la selection sur l'element courant
Me.ComboBox1.SelectedIndex = currentPos
End Sub
End Class |
Partager