Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
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
|