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 35 36 37 38
|
Public Class Form1
Sub New()
' Cet appel est requis par le concepteur. (Charge le designer de Form1)
InitializeComponent()
' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
' Paramétrage dynamique du combobox (settings + ajout d'items) !
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
' Solution 1
ComboBox1.Items.AddRange(New String() {"http://www.Assetto-Corsa.fr", "http://www.Assetto-Corsa.net", "http://www.racedepartment.com", "http://acmods.net", "http://www.drivingitalia.net"})
' Solution 2
' ComboBox1.Items.AddRange(New String() {"Assetto-Corsa.fr", "Assetto-Corsa.net", "racedepartment.com", "acmods.net", "drivingitalia.net"})
' On sélectionne le 1er item par défaut
ComboBox1.SelectedIndex = 0
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Il n'est pas toujours nécessaire d'utiliser ce gestionnaire d'évènement Load !!!!!
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' Solution 1 :
Process.Start(ComboBox1.SelectedItem)
' Solution 2 : Le préfixe n'est pas toujours le même suivant le site sélectionné dans la liste alors on impose une conditionnelle pour retourner l'url correcte !
' Select Case ComboBox1.SelectedIndex
' Case 0, 1, 2, 4
' Process.Start("http://www." & ComboBox1.SelectedItem)
' Case 3
' Process.Start("http://" & ComboBox1.SelectedItem)
' End Select
End Sub
End Class |
Partager