The project in the book does not function correctly. Nor does the downloadable version from this site. You are right at the chapter where everything goes awry.
I have been going back and forth, via email, about this and so far have been unsuccessful.
Code:
Private Sub btnAddPerson_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddPerson.Click
objPersonalDetails = New PersonalDetails
Dim objPerson As New Person("Glenda", "Brown")
With objPerson
.BirthDate = "1965-12-02"
.Address = "333 Green Valley Way, Los Angeles, CA"
.HomePhone = "(811) 8888 7777"
End With
objPersonalDetails.Person = objPerson
Me.Text = "Personal Organizer - Viewing " + _
objPersonalDetails.Person.DisplayName
objPersonalDetails.AddMode = True
If pnlMain.Controls.Contains(objPersonList) Then
pnlMain.Controls.Remove(objPersonList)
objPersonList = Nothing
End If
pnlMain.Controls.Add(objPersonalDetails)
objPersonalDetails.Dock = DockStyle.Fill
Don't forget this in PersonalDetails.
vb, though:
Code:
Public Class PersonalDetails
Private mPerson As Person
Private mAddMode As Boolean
Public Property AddMode() As Boolean
Get
Return mAddMode
End Get
Set(ByVal value As Boolean)
mAddMode = value
If mAddMode = True Then
SetUpButtons()
Else
RemoveButtons()
End If
End Set
End Property