StrataFrame Forum

How do I...Return the selected record

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

By Ben Kim - 1/30/2007

Hello all,

Say I have an entry form with several fields that are related to lookup tables.

Entry Form
    Person Hair Color
    Person Eye Color

The hair and eye colors come from a lookup table.   I want to present a browse list of available options, allow them to enter new categories, and return a single selected record back to the main entry form.

Is there an example on how to do this with StrataFrame?

Ben

By Greg McGuffey - 1/30/2007

I'm sure there is a fancy SF way, but as I've not had the training (yet), I don't know it.



However, just using normal .NET techniques is pretty easy. Build your browse form with whatever functionality you want. I've done forms with tree views and with lists, both with associated editors for the selected item (i.e. they click on tree or list and BO navigates to associated item, there is an editing area, where they can edit/delete/add items (as makes sense)).



Then just have a public property that returns whatever you need in the calling form. I usually return the PK of the browsed item. The key is that you can return information about the current row in the BO.



Public Property ItemPK() as Integer

Get

' myBO is the BO on browse form, PkField is the strongly typed

' property for the pk of the item in browse dialog

me.myBO.PkField

End Get

End Property



Lastly, you will want to have a cancel and OK button that return DialogResults of Cancel and OK respectively, which sets the dialog result and hides the form.



Private Sub btnCancel_Click(sender as Object, e As EventArgs) Handles btnCancel.Click

Me.DialogResult = Windows.Forms.DialogResult.Cancel

End Sub



Private Sub btnOK_Click(sender as Object, e As EventArgs) Handles btnOK.Click

Me.DialogResult = Windows.Forms.DialogResult.OK

End Sub



The calling form uses a ShowDialog() and after the browse form closes, get the value from the property.



Private Sub btnGetHairColor_Click(sender as Object, e As EventArgs) Handles btnGetHairColor.Click

Using frm as New HairColorForm()

frm.ShowDialog(Me)

If frm.DialogResult = Windows.Forms.DialogResult.OK Then

' Set hair color here

dim hairColorPK as Integer = frm.ItemPK ' from property above

End If

End Using

End Sub
By Trent L. Taylor - 1/30/2007

In this example the best solution would be using a combo box and having the combo populate itself using the "BusinessObject" option.  There are a number of samples that show the advanced list population within StrataFrame.  You can see this in the Advanced ListView Population sample or the combo boxes in the sample CRM Application on the Customer Maintenance Form show this as well.

You can use the BrowseDialog, which there is a sample for the BrowseDialog as well, but in this case I would think a combo box would be the way to go.