I have an app written in vb.net 1.1 and am learning how to bind the form's
controls to its business class properties. The business class is not an
item in a list of business objects, but rather each record is retrieved
separately from the database. I've seen lots of examples of updating the
controls on the form when the datasourse is a list, but in this case its
just a single instance of a business class which may fetch a different
record from the database and populate its properties with the value from
this fetched record. I want to know the most proper way of having the bound
controls in form refresh with these new values. I figured out a way, but it
seems like a hack. Here's the short version of my code:

'Textbox on form if called FName
'Property in business class is called FName

'custom dec.s in form
Private WithEvents objB As Person_BLL = New Person_BLL
Private WithEvents _bmb As BindingManagerBase

'in the form load event:
Me.FName.DataBindings.Add("Text", objB, "FName")

'custom dec.s in biz class

Private Structure Props
Dim ID As Int32
Dim FName As String
Dim MName As String
Dim LName As String
End Structure

Public Event FNameChanged As EventHandler
Public Event MNameChanged As EventHandler
Public Event LNameChanged As EventHandler

'One of the props in biz class
Public Property FName() As String
Get
Return DataProps.FName
End Get
Set(ByVal Value As String)
DataProps.FName = Trim(Value)
RaiseEvent FNameChanged(Me, New EventArgs)
End Set
End Property

'Get data from db

Public Sub GetRec()
'Fetch data from database
'set datarow object to datarow of dataset
'now set value for properties
DataProps.FName = dr.FName
DataProps.MName = dr.MName
DataProps.LName = dr.LName
'Now raisevent to refresh the FName textbox in the winform
RaiseEvent FNameChanged(Me, New EventArgs)
'Note: by raising this one event, all the bound controls were refreshed in
the UI
'I could have called MNameChanged or LNameChanged
'but I only needed to raise one. This seems like a hack
End sub

Rather than arbitrarily raising one of the properties changed, isn't there a
proper way to refresh everything in one call?

Any good overall-advise for this setup?

Thanks.

--
moondaddy@nospam.com