StrataFrame Forum

BO form with a drop down list to pick a related BO

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

By thegwill - 9/18/2007

I cannot get my WinForms app to work correctly with my related business objects.

I have the following object model:

  • BOMain links to exactly 1 BOLookup so it has a FK to BOLookup. i.e. BOMain.FK_Lookup

I have a maintenance form to maintain BOMain objects. The form has a drop-down list to choose a BOLookup to link the BOMain instance to.

The problem I'm having is with the BOLookup drop-down list. I cannot get any items to appear in the drop down list. I can confirm the following:

  • The database is populated correctly
  • I have a BO for BOLookup
  • I have a BO for BOMain
  • I have created a .ParentRelationship on BOMain to wire up to BOLookup
  • My form has a BOMain "object" (named BOMainInstance for this example)
  • My form has the .PrimaryBusinessObject = BOMainInstance
  • My form has a SF combo control with the following settings: .BindingField = FK_Lookup, .BusinessObject = BOMain, .PopulationDataSource = BOLookup.FillAll(), .PopulationType = BusinessObject
  • My form does NOT have a BOLookup "object" as I believe the combo control will create its own instance behind the scenes
  • All other data maintenance functionality on the form is working correctly

I'm expecting the drop down to sync with the correct linked object for existing records and allow the user to choose an alternate linked item to link to

When I run the app, the drop down list on the form is always empty. When the drop down is expanded, it shows a number of "blank" rows (which is the same number of rows as there are in the Lookup table so I'm assuming the relationship is "working" but the UI isn't set up correctly)

Any ideas what I've missed?

By StrataFrame Team - 9/19/2007

When you set the PopulationDataSourceSettings, did you specify the fields to display within the combo box?  You will need to add the fields to display to the list and each will be assigned an index.  Once they are assigned indexes ({0}, {1}, {2}...{n}), you will need to set the display value.  The display value will be a String.Format expression that contains replacement values for the fields you chose to display.  So, if you choose, say, Name and Description as your two fields and Name as assigned {0} and Description was assigned {1}, then your display value will need to be "{0} - {1}"  If you leave the Display Value blank, the combo box will literally display a blank value for each of the items within it.

Other than that, everything you've done is correct.  Just make sure you have the lookup pk value set as the Value within the PopulationDataSourceSettings.

By thegwill - 9/19/2007

Thanks Ben - spot on Wink
By StrataFrame Team - 9/20/2007

No problem.  I also forgot to mention that since it's a String.Format replacement string, you can put formatting values after a : in the replacement tag.  So, if you have a value of 1200

{0} will print 1200

{0:C} will print $1,200

{0:N2} will print 1,200.00

Just FYI.  And you can get a full list of the format strings through the .NET documentation by searching for format strings.  There are tons of them for dates, too ({0:MM/dd/yyyy}).