StrataFrame Forum

Listbox valueMember

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

By Daniel Essin - 3/8/2006

I am trying to use your listbox. I have set the PopulationType to BusinessObject and set the PopulationDataSourceSettings including specifying the ValueMember. This does not fill in the valuemember property of the control and if try to set that directly the popup menu only offers none. upon Execution I get:



InvalidOperationException

   Cannot set the SelectedValue in a ListControl with an empty ValueMember.



Source : System



Could you please straighten me out on this?
By StrataFrame Team - 3/8/2006

Within the population data source settings, set the Value Member to whatever field you want to use as the selected value. Then, in the property sheet for the ListControl, right-click the ValueMember property name and select "Reset" from the context menu. When the list is populated at runtime, the ValueMember property will be dynamically set to the name of the dynamically created DataTable that is used as the list source.



Also, make sure the "Value Member" within the PopulationDataSourceSettings dialog is set to the name of a valid field on the business object.



If resetting the ValueMember property doesn't work, then make sure you're not setting the ValueMember anywhere in code. If that still does not work, post some screenshots of your configurations, and maybe I can make something of it.
By Daniel Essin - 3/8/2006

I have attached a screen-shot.



The reset option is grayed-out on ValueMember.



I am also unclear about needing to set the BusinessObject property and the DataSource property. It seems like setting the businessObject would be sufficient. In any case I have tried it with and without the datasource being set and the control comes up empty.



I am populating a c1TrueDataGrid simultaneously from the same BO as a test and it displays data.
By Trent L. Taylor - 3/10/2006

Daniel,

Could you please email the picture.  It was shurnk when added and there fore unreadableBigGrin  Thanks.

By Daniel Essin - 3/10/2006

I can't upload anything. It says that I have used 480 of 512 kb.
By Trent L. Taylor - 3/13/2006

There is more than one way to populate a list using a business object. The manual method which would entail you use the DataSource, DisplayMember, and ValueMember properties.  The other is to set the PopulationType to BusinessObject and set the PopulationDataSourceSettings property.  For an exmaple or a reference on how to do this, refer to this thread on the forum: http://forum.strataframe.net/Topic596-6-1.aspx .  If this doesn't help let me know.
By Daniel Essin - 3/13/2006

How would I set the DataSource, DisplayMember, and ValueMember properties?
By Trent L. Taylor - 3/13/2006

All listboxes have a DataSource, ValueMember, and DisplayMember as does a combo box.  To use those properties add something like this:

MyListBox.DisplayMember = "MyDisplayFieldName"
MyListBox.ValueMember = "MyValueFieldName - Usually a PK of some sort"
MyListBox.DataSource = MyBusinessObject.CurrentDataTable

That's it Smile