Charles: The way I did this was to add a State table to the SF Sample database. The table consists of StateName and StateCode columns. StateName has the long names and StateCode has the abbreviations. Then I went into the VB.NET CRMApplication sample. I added a BO called StateBO to that project and used the BusinessObjectMapper to create the partial class for it.
I added the following custom code to the StateBO for a parameterless data retrieval method:
''' <summary>''' Fills the business object with all records order by primary key''' </summary>''' <remarks></remarks>Public Sub FillAllStateTable()'-- Establish localDim loCommand As New SqlCommand()'-- Create the commandloCommand.CommandText =
"SELECT * FROM State ORDER BY StateCode"'-- Execute the commandMe.FillDataTable(loCommand)End Sub#
End Region Then I modified the custom code for the CustomersBO by adding the following lines of code only:
Private WithEvents _State As New StateBO()
''' <summary>''' This method handles the Navigated event of the Customers business object to allow''' you to set the filter on the State business object.''' ''' You can filter the StateBO to only show records that match the current record''' within the CustomersBO.''' </summary>''' <param name="e"></param>Private Sub CustomersBO_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles Me.Navigated'-- Set the filter on the internal StateBO' (Only necessary if the CompanyBO will contain more than one record)Me._State.Filter = "StateCode = '" & CType(Me.CurrentRow("cust_State"), String) & "'"End Sub Next I did a BuildAll so that the Company and State Business Objects were recompiled.
To test it, I moved the State Textbox (Textbox9) to the bottom of the form (you could just as easily remove it) and replaced it with a StrataFrame ComboBox on which I set the following properties: BusinessObject=Customers, BindingField = cust_State, DropDownStyle=DropDownList, PopulationType=BusinessObject, PopulationDataSourceSettings=StateBO.FillAllStateTable(). The PopulationDataSourceSettings property gets built by clicking the ellipsis on the property. Inside there I put {0} under Display Member and Drop-Down Display, StateName under ValueMember and added StateCode to DisplayMember.
When you run the form the combo box will display the state code for the current record as you browse. If you edit/add a record the combo box displays a list of all possible state codes. If you change a value and save it, the Customers table will save the state name associated with the state code.
That should get you started if you're still looking at this.