Results 1 to 2 of 2

Thread: No items shown in the ComboBox

  1. #1

    No items shown in the ComboBox

    Hi,

    I am a newer in C#. I created a ComboBox, but it didn't show any items. After clicking, the only item is 'none'. Can anybody help me with this. Thank you!

    Here is part of the code:

    classTestReport : Report
    {

    private ComboBoxtcombo = newComboBox();
    privatestring[] comboNames = { "A1", "A2", "A3", "A4" };
    privateList<string> comboNames2 = newList<string>();
    privatestring secretString2 = "A1";

    public TestReport()
    {
    tcombo.DataSource = comboNames;

    }
    publicComboBox Test
    {
    get
    {
    tcombo.DropDownStyle = ComboBoxStyle.DropDownList;
    return tcombo;
    }
    set
    {
    tcombo = value;
    tcombo.DropDownStyle = ComboBoxStyle.DropDownList;
    }
    }

  2. #2
    You didn't databind your combobox. You need to call the databind method on your combobox after you set the datasource:

    Code:
    
    tcombo.DataSource = comboNames;
    tcombo.DataBind();
    
    


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012