Hi this is my first week in vb.net
I m using visual studio 2010, I am trying to show the week days in Combo box but its not showing when i run it. plz help!


Class MainWindow

Private Sub ComboBox1_SelectionChanged(sender As System.Object, e As System.Windows.Controls.SelectionChangedEventArgs) Handles ComboBox1.SelectionChanged


Dim listofdays As New List(Of String)
listofdays.Add("Monday")
listofdays.Add("Tuesday")
listofdays.Add("Wednesday")
listofdays.Add("Thursday")
listofdays.Add("Friday")
listofdays.Add("Saturday")
listofdays.Add("Sunday")
ComboBox1.ItemsSource = listofdays

End Sub
End Class

I have got it, this code has to be written in windows load event
works now :)

For what it's worth:
If you needed to change the contents of the combobox in response to an event (such as the user making a selection in another combobox). You should use update panels (or javascript...).

Such (html) code would look like:

<asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
    
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        'Your combobox here
        </ContentTemplate>
        </asp:UpdatePanel>

The script manager is there to handle Ajax controls since they cannot work without one (and update panels are Ajax). The update panel needs the content template tags so that it knows which controls are inside of it.

Again I realize you've solved this issue, but hopefully this will help someone in the future.

Try using DataSource property to bind the data with the contorol:

Dim listofdays As New List(Of String)()
'populate the list
'then bind comboBox with the generic list<T>:
comboBox1.DataSource = listofdays
This article has been dead for over six months. Start a new discussion instead.