copyright 1999 - 2014 by heinz prelle - hannover  - lenbachstraße 42 - www.visual-basic5.de | impressum
Beispiel: VB .Net - ComboBox mit Monatsnamen füllen
'
Option Explicit On
Option Strict On

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
            Handles MyBase.Load
        With Me
            .Text = "ComboBox mit Monatsnamen fuellen"
            .CenterToScreen()
            .Button1.Text = "Laden"
        End With
    End Sub

    Private Function FillComboBoxWithMonthNames() As List(Of String)
        Dim List As New List(Of String)
        For n As Integer = 1 To 12
            List.Add(Microsoft.VisualBasic.MonthName(n))
        Next
        Return List
    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
            Handles Button1.Click
        Me.ComboBox1.Items.AddRange(Me.FillComboBoxWithMonthNames().ToArray())
        If Me.ComboBox1.Items.Count > 0 Then Me.ComboBox1.SelectedIndex = 0
    End Sub

End Class
Sourcecode Visual Basic