Allow Null In Combo Box

I have a combo box, that has its datasouce, valuemember, and display members set. I need to allow the user to leave the null. I need the combo box to be null when the form loads, and allow nulls if the user does not wish to select anything. It is for a search criteria form. Does anyone have any suggestions

Thanks




Answer this question

Allow Null In Combo Box

  • BlackMan890

    You can add a null value to a combobox, you have to insert a empty string instead.


  • RGriffin

    why not add a listitem with value "" and a space in it.

    Listitem i = new ListItem;
    i.Value = "";
    i.Text = "";
    myComboBox.Add(i);

    hth,



  • dophine

    hi ,

    just give the first value in the items list as an empty string that shud do the job


  • Frankie Ho

    All your answers are great, but I have tried that. The fact is that you can not add items to a combo box once its datasource property, lookupvalue, and display memeber has been set. Maybe I will leave out the lookupvalue and displaymember, and do it the old fashion way.

  • wgillin

    I added an empty string to the list of items, then looped through my datasource adding items after the empty string.

  • Allow Null In Combo Box