Hi I am New to C# i Am trying to create a grade book form but I cannot build successfully because of the following error.
The name 'InitializeComponent' does not exist in the current context
// Fig. 19.7: GradeBook.cs
// A reusable Windows Form for the examples in this chapter.
using System;
using System.Windows.Forms;
namespace GradeBook
{
public partial class GradeBook : Form
{
protected int TextBoxCount = 5; // number of TextBoxes on Form
// enumeration constants specify TextBox indices
public enum TextBoxIndices
{
LAST,
FIRST,
ID,
CLASS,
GRADE,
} // end enum
// parameterless constructor
public GradeBook()
{
InitializeComponent();
} // end constructor
// clear all TextBoxes
public void ClearTextBoxes()
{
// iterate through every Control on form
foreach ( Control guiControl in Controls )
{
// determine whether Control is TextBox
if ( guiControl is TextBox )
{
// clear TextBox
( ( TextBox ) guiControl ).Clear();
} // end if
} // end for
} // end method ClearTextBoxes
// set text box values to string array values
public void SetTextBoxValues( string[] values )
{
// determine whether string array has correct length
if ( values.Length != TextBoxCount )
{
// throw exception if not correct length
throw ( new ArgumentException( "There must be " +
( TextBoxCount + 1 ) + " strings in the array" ) );
} // end if
// set array values if array has correct length
else
{
// set array values to text box values
lastNameTextBox.Text = values[ ( int ) TextBoxIndices.LAST ];
firstNameTextBox.Text = values[ ( int ) TextBoxIndices.FIRST ];
iDTextBox.Text = values[ ( int ) TextBoxIndices.ID ];
classTextBox.Text = values[ ( int ) TextBoxIndices.CLASS ];
gradeTextBox.Text = values[ ( int ) TextBoxIndices.GRADE ];
} // end else
} // end method SetTextBoxValues
// return text box values as string array
public string[] GetTextBoxValues()
{
string[] values = new string[ TextBoxCount ];
// copy text box fields to string array
values[ ( int ) TextBoxIndices.LAST ] = lastNameTextBox.Text;
values[ ( int ) TextBoxIndices.FIRST ] = firstNameTextBox.Text;
values[ ( int ) TextBoxIndices.ID ] = iDTextBox.Text;
values[ ( int ) TextBoxIndices.CLASS ] = classTextBox.Text;
values[ ( int ) TextBoxIndices.GRADE ] = gradeTextBox.Text;
return values;
} // end method GetTextBoxValues
} // end class GradeBook.cs
} // end namespace GradeBook