StrataFrame Forum

Combobox in unbound mode

http://forum.strataframe.net/Topic31847.aspx

By Thomas Holste - 2/20/2013

Hi there,

I use a combobox in unbound mode and populate the dropdown-part by using a business-object. When I now call the form, instead of a blank value in the entry-part of the combobox, I always get the first entry of the "dropdown-part-bo" as a already given value. What can I do to prevent this?

Best regards

Thomas
By StrataFrame Team - 2/21/2013

That is the default behavior of the ComboBox; when it has items, it does not allow a selection that is not included in the data source.  We added the TopMostItem property specifically to allow for this.  Set the TopMostItem.Description and .Value to the desired values.  It forces the item to show up as the first item in the drop down.  
By Thomas Holste - 2/21/2013

Hi Ben,

<<That is the default behavior of the ComboBox; when it has items, >>

just to be sure to understand it. My combobox has no bindingfield and no businessobject set but the populationtype-property is set to businessobject and the populationdatasourcesettings are set to BO, its fill-method and its fiields.

So "items" does also means this?

Thanks and best regards

Thomas

 

 
By StrataFrame Team - 2/21/2013

Yes, when you set the DataSource/DisplayMember/ValueMember of a ComboBox or ListBox (which is what SF does when you populate through the business object), the control uses those values to populate its Items collection.  

What I meant by default behavior is that when you have Items in the ComboBox and it's set to the mode of DropDownList, it has to have a selected value if it's not bound.  It won't let you "select none."  It always wants to select an item when the form opens up.  You might be able to jack with it if you set the SelectedValue to null/Nothing, but it's easier to just put a TopMostItem in the list so that the users can have a way to "deselect" the items in the list or "select none."

We generally have a TopMostItem of "<none>" with a value of 0 or null, or "<please select provider>" with a value of 0.
By Thomas Holste - 2/21/2013

Hi Ben,

again thanks a lot for your advice.

Best regards

Thomas