Errata

All errata for Windows Forms in Action will be posted here and updated periodically.

If you discover additional mistakes in the book, please post them to the Author Online forum.


Chapter 5:

Page 122:

Step 1, Result, in the code, class Photograph  should be  public class Photograph

Chapter 6:

Page 156:

Step 14, in the code, if (Index >= Album.Count)  should be  if (Index >= Album.Count - 1)

Page 169:

Step 1, Result, change the code starting with public AlbumManager... and subsequent lines to insert the two additional lines shown here.
public AlbumManager(string name) : this()
{
  _name = name;
  _album = AlbumStorage.ReadAlbum(name);

  if (Album.Count > 0)
    Index = 0;
}

Chapter 8:

Page 236:

Step 3, in the ResetDialog() method, replacing txtDateTaken with mskDateTaken only works if the date month has two digits. In this method, the mskDataTaken.Text property should be assigned as
mskDateTaken.Text = photo.DateTaken.ToString("MM/dd/yyyy");

Chapter 9:

Page 249:

Step 1, Action: MyAlbumControls  should be  MyPhotoControls

Chapter 10:

The implementation of the FlybyTextProvider class has a slight error that causes a problem in some situations. The following changes address this problem.

Page 278:

Step 4: add a boolean private field
private bool _set = false;
Step 5: add a private property
private bool IsSet
{
  get { return _set; }
  set { _set = value; }
}

Page 279:

Step 9, rewrite ShowFlyby() as
private void ShowFlyby(object item)
{
  string flybyText = FlybyTable[item] as string;
  if (flybyText != null && StatusLabel != null)
  {
    if (!IsSet)
    {
      CurrentStatusText = StatusLabel.Text;
      IsSet = true;
    }
    StatusLabel.Text = flybyText;
  }
}
Step 10, rewrite RevertFlyby() as
private void RevertFlyby(object item)
{
  if (StatusLabel != null && IsSet)
  {
    StatusLabel.Text = CurrentStatusText;
    CurrentStatusText = null;
    IsSet = false;
  }
}

Page 290:

Step 7, in the code, EndsWish  should be  EndsWith

Page 293:

Step 1, rewrite the constructor as
public AlbumManager(string name, string pwd)
  :

this()
{
  _name = name;
  _album = AlbumStorage.ReadAlbum(name, pwd);
  Password = pwd;

  if (Album.Count > 0)
    Index = 0;
}

Chapter 12:

Page 337:

Step 2, Settings table: change MaxDropDown to MaxDropDownItems.

Page 338:

Step 8, The line assigning the mskDateTaken.Text property should be:
mskDateTaken.Text = photo.DateTaken.ToString("MM/dd/yyyy");

Page 355:

Try It: The code shown here should be:
CustomPhotoFormatter photoFormatter;
photoFormatter = new CustomPhotoFormatter();
Photograph photo = new Photograph("c:

\\temp\\MyRedImage.bmp");
Console.WriteLine(String.Format(photoFormatter,
    "The pixel at (100,100) is {0:

p100,100}", photo));

Chapter 14:

Page 406:

Step 4: in the table, Border-Style should be BorderStyle

Chapter 16:

Page 451:

Step 5: How-to, part b, this should say "Ctrl key" rather than "Shift key." Using the shift key also selects the ToolStripSeparators, which is incorrect.

Page 455:

Step 1: In the Settings table, change Magenta to Fuchsia. While writing this Chapter, the Magenta setting worked just fine. While compiling the code for posting, I had to change Magenta to Fuchsia.

Chapter 17:

Page 481:

Step 4: The Action here should say "Add the existing MyPhotoControls and MyPhotoAlbum projects to the solution."

Chapter 18:

Page 532:

Step 2: the if statement here should look as follows. This avoids a small problem if a user enters a bad password for an encrypted album.
if (e.Node is AlbumDirectoryNode)
  ExpandAlbumDirectory(e.Node as AlbumDirectoryNode);
else if (e.Node is AlbumNode)
  e.Cancel = !ExpandAlbum(e.Node as AlbumNode);
Step 4: change ExpandAlbum to return a boolean value:
private bool ExpandAlbum(AlbumNode node)
{
  AlbumManager mgr = node.GetManager(true);
  if (mgr != null)
  {
    BeginUpdate();
    try
    {
      node.Nodes.Clear();
      foreach (Photograph p in mgr.Album)
      {
        PhotoNode newNode = new PhotoNode(p);
        node.Nodes.Add(newNode);
      }

      return true;
    }
    finally { EndUpdate(); }
  }
  else
    return false;
}

Chapter 20:

Page 598:

Step 6: In both the Action and Result, the name UpdatePixelData  should be  UpdatePixelDialog

Page 603:

Step 2: In the Settings table, remove the first Text entry with value &Window. The second Text entry here is correct.

Chapter 21:

Page 629:

The title for the Action-Result table on this Page should be "Handle the Click event in the Edit menu item"

Page 629:

Step 4: the code shown for the SetDataSources() method should be:
private void SetDataSources()
{
  gridPhotoAlbum.DataSource = Manager.Album;
  SetComboColumnDataSource();
}

Chapter 22:

Page 641:

The title for the first Action-Result table on this Page should be "Modify PhotoAlbum to use generic BindingList class"

Page 641:

Step 1, The Action text should be "In the PhotoAlbum.cs file of the MyPhotoAlbum project, indicate we use the ComponentModel namespace."

Chapter 23:

Page 667:

Step 9 and 10: the order of the code here does not match the text. The Page Setup Click handler code should be in Step 9, and the other two event handlers in Step 10.