ComboBox1.Items.Clear() For i = System.DateTime.Now.Year To 1960 Step -1 ComboBox1.Items.Add(i.ToString) Next ComboBox1.SelectedIndex = 0
Public Class ComboYears Inherits ComboBox Private pAnneeDebut As Integer = 1960 Private pAnneeFin As Integer = System.DateTime.Now.Year() Private pRemplir As Boolean = True <System.ComponentModel.Category("Remplissage Auto"), System.ComponentModel.Description("Année de début")> _ Public Property Debut() As Integer Get Return Me.pAnneeDebut End Get Set(ByVal value As Integer) Me.pAnneeDebut = If(value > Me.pAnneeFin, Me.pAnneeFin, value) If Not Me.DesignMode Then Me.FillList() End Set End Property <System.ComponentModel.Category("Remplissage Auto"), System.ComponentModel.Description("Année de fin")> _ Public Property Fin() As Integer Get Return Me.pAnneeFin End Get Set(ByVal value As Integer) Me.pAnneeFin = If(value < Me.pAnneeDebut, Me.pAnneeDebut, value) If Not Me.DesignMode Then Me.FillList() End Set End Property <System.ComponentModel.Category("Remplissage Auto"), System.ComponentModel.Description("Autorise ou non le remplissage automatique")> _ Public Property Remplir() As Boolean Get Return Me.pRemplir End Get Set(ByVal value As Boolean) Me.pRemplir = value If Not Me.DesignMode Then Me.FillList() End Set End Property Private Sub FillList() Me.Items.Clear() If Me.pRemplir Then For i As Integer = Me.pAnneeFin To Me.pAnneeDebut Step -1 Me.Items.Add(i) Next i End If End Sub End Class