StrataFrame Forum

combobox-question

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

By Thomas Holste - 4/28/2014

Hi there,

is it possible to fill the dropdown-list of a multi-column combobox manually? And how has this to be done?

Thanks in Advance

Thomas
By Edhy Rijo - 4/28/2014

Hi Thomas,

I have never had the need to manually populate a comobox, but it is doable.  Based on the SF help file "List Control Population" you need to follow the examples in the Microsoft's .NET Developers Guide.

Now back to your question, do you really need to populate the list manually or will you be using any of the SF sources?   Be aware that you can show multiple columns with SF population events.
By Thomas Holste - 4/28/2014

Hi Edhy,

thanks for your reply. I use the combobox already with using the VO-populationtypwe. But there are two reasons ti add items manually

. The dropdown-items are generated dynamically and

- I have encountered some problems with combo-boxes populated by a BO (This will be a new topic)

Populating a combobox is not a problem, but I was curious if I can populate a sf-combobox with a multiline dropdown-list.

Best regards

Thomas
By StrataFrame Team - 4/30/2014

Howdy Thomas,

Yes, you can use the MultiColumns and populate manually, but you still have to use the .NET-style data source for the combo box.  Basically, you have to have a list behind the combo box that defines the items, and the easiest way to do this is with a DataTable, but you can just as easily create a custom class with a few properties and use a generic list with a BindingSource, but the DataTable already has all of those interfaces on it.

  1. Create a DataTable with 3 columns, "Display" (string), "Value" (object), and "DropDown" (string).  
  2. Populate it with rows for the items you want in the combo box
    1. The value in the Display column will show as the selected item when the combo box is closed
    2. The value in the Value column will be the SelectedValue on the combo box for binding
    3. The value in the DropDown column will be what is used to render the drop down.  Combine all of the columns into this field and pipe delimit them:  "Column 1|Column 2|Column 3"  The pipes are used to split the columns when rendering the drop down.
  3. Set the UseMultiColumns to true
  4. Set DropDownMember to "DropDown"
  5. Set DisplayMember to "Display" 
  6. Set ValueMember to "Value"
  7. Set the DataSource property to your data table.
That should do it.  Anything you put into the DataTable gets added as a row in the combobox.
By Thomas Holste - 5/6/2014

Hi Ben,

thanks for the explanation, I will try it immediately.

Best regards

Thomas