#pragma once

namespace Hardware_Store {

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;

    /// <summary>
    /// Summary for Form1
    /// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
         //array variables
              private: array<String^>^itemNoA;
              private: array<String^>^descriptionA;
              private: array<int^>^noStockA;
              private: array<double^>^priceA;
    public:
        Form1(void)
        {
            InitializeComponent();
            //create array variables
              itemNoA = gcnew array<String^>(10);
              descriptionA = gcnew array<String^>(10);
              noStockA = gcnew array<Int32^>(10);
              priceA = gcnew array<Double^>(10);

             //read the data from the file
               readFile( );


            //
            //TODO: Add the constructor code here
            //
        }

    protected:
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::Label^  label1;
    protected: 
    private: System::Windows::Forms::Label^  label2;
    private: System::Windows::Forms::TextBox^  textBox1;
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::DataGridView^  searchResults;
    private: System::Windows::Forms::DataGridViewTextBoxColumn^  itemNo;
    private: System::Windows::Forms::DataGridViewTextBoxColumn^  description;
    private: System::Windows::Forms::DataGridViewTextBoxColumn^  noStock;
    private: System::Windows::Forms::DataGridViewTextBoxColumn^  price;

    private:
        /// <summary>
        /// Required designer variable.
        /// </summary>
        System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        void InitializeComponent(void)
        {
            System::Windows::Forms::DataGridViewCellStyle^  dataGridViewCellStyle1 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
            System::Windows::Forms::DataGridViewCellStyle^  dataGridViewCellStyle2 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
            this->label1 = (gcnew System::Windows::Forms::Label());
            this->label2 = (gcnew System::Windows::Forms::Label());
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->searchResults = (gcnew System::Windows::Forms::DataGridView());
            this->itemNo = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
            this->description = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
            this->noStock = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
            this->price = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->searchResults))->BeginInit();
            this->SuspendLayout();
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->label1->Location = System::Drawing::Point(250, 34);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(234, 24);
            this->label1->TabIndex = 0;
            this->label1->Text = L"Chin Chin Hardware Store ";
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->Location = System::Drawing::Point(181, 85);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(47, 13);
            this->label2->TabIndex = 1;
            this->label2->Text = L"Item No.";
            // 
            // textBox1
            // 
            this->textBox1->Location = System::Drawing::Point(254, 82);
            this->textBox1->Name = L"textBox1";
            this->textBox1->Size = System::Drawing::Size(100, 20);
            this->textBox1->TabIndex = 2;
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(409, 75);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(75, 23);
            this->button1->TabIndex = 3;
            this->button1->Text = L"Search";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
            // 
            // searchResults
            // 
            this->searchResults->AccessibleName = L"";
            this->searchResults->AllowUserToAddRows = false;
            this->searchResults->AllowUserToDeleteRows = false;
            dataGridViewCellStyle1->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter;
            dataGridViewCellStyle1->BackColor = System::Drawing::SystemColors::Control;
            dataGridViewCellStyle1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            dataGridViewCellStyle1->ForeColor = System::Drawing::SystemColors::WindowText;
            dataGridViewCellStyle1->SelectionBackColor = System::Drawing::SystemColors::Highlight;
            dataGridViewCellStyle1->SelectionForeColor = System::Drawing::SystemColors::HighlightText;
            dataGridViewCellStyle1->WrapMode = System::Windows::Forms::DataGridViewTriState::True;
            this->searchResults->ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
            this->searchResults->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
            this->searchResults->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^  >(4) {this->itemNo, 
                this->description, this->noStock, this->price});
            dataGridViewCellStyle2->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter;
            dataGridViewCellStyle2->BackColor = System::Drawing::SystemColors::Window;
            dataGridViewCellStyle2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, 
                System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
            dataGridViewCellStyle2->ForeColor = System::Drawing::SystemColors::ControlText;
            dataGridViewCellStyle2->SelectionBackColor = System::Drawing::SystemColors::Highlight;
            dataGridViewCellStyle2->SelectionForeColor = System::Drawing::SystemColors::HighlightText;
            dataGridViewCellStyle2->WrapMode = System::Windows::Forms::DataGridViewTriState::False;
            this->searchResults->DefaultCellStyle = dataGridViewCellStyle2;
            this->searchResults->Location = System::Drawing::Point(134, 159);
            this->searchResults->Name = L"searchResults";
            this->searchResults->ReadOnly = true;
            this->searchResults->Size = System::Drawing::Size(445, 94);
            this->searchResults->TabIndex = 4;
            // 
            // itemNo
            // 
            this->itemNo->HeaderText = L"Item No.";
            this->itemNo->Name = L"itemNo";
            this->itemNo->ReadOnly = true;
            // 
            // description
            // 
            this->description->HeaderText = L"Description";
            this->description->Name = L"description";
            this->description->ReadOnly = true;
            // 
            // noStock
            // 
            this->noStock->HeaderText = L"No. In Stock";
            this->noStock->Name = L"noStock";
            this->noStock->ReadOnly = true;
            // 
            // price
            // 
            this->price->HeaderText = L"Price";
            this->price->Name = L"price";
            this->price->ReadOnly = true;
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(724, 354);
            this->Controls->Add(this->searchResults);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->textBox1);
            this->Controls->Add(this->label2);
            this->Controls->Add(this->label1);
            this->Name = L"Form1";
            this->Text = L"Form1";
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->searchResults))->EndInit();
            this->ResumeLayout(false);
            this->PerformLayout();

        }
#pragma endregion
        private: void readFile(void){

 //create file stream variable and associate with text file
 StreamReader^ inData = gcnew StreamReader("hardware.txt");

 //other variables
 array<String^>^line = gcnew array<String^>(4);
 String^ record;
 array<Char>^ delimeter = gcnew array<Char>{'#','\n'};

//read the contents of the file an store in an array
 int i = 0;

 while ( !inData->EndOfStream ){
      record = inData->ReadLine( );  //read a line
      line = record->Split(delimeter);       //split the line
//assign the components
         this->itemNoA[i] = line[0];
        this->descriptionA[i] = line[1];
        this->priceA[i] = Convert::ToDouble(line[2]);
        this->noStockA[i] = Convert::ToInt32(line[3]);
        ++i;
   }//end while
    }//end read file function

    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                         bool found = false;

  //delete any previous search results if they exist
     if( searchResult->Rows->Count > 0)
            this->searchResult->Rows->RemoveAt(0);
//search the array
 for(int d=0; d<this->itemNoA->Length;++d){
      if(String::Compare(textBox1->Text,
                   this-> itemNoA[d], true)==0){
         this->searchResult->Rows->
             Add(this->itemNoA[d], this->descriptionA[d],
                          this->priceA[d], this->noStockA[d]);
       found = true;
        break;
 }//end if found
 }//end for

             }
};
}

My errors are :

Error 1 error C2065: 'StreamReader' : undeclared identifier c:\users\user\documents\visual studio 2010\projects\hardware_store\hardware_store\Form1.h Line 204

Error 2 error C2065: 'inData' : undeclared identifier c:\users\user\documents\visual studio 2010\projects\hardware_store\hardware_store\Form1.h Line 204

Error 3 error C2061: syntax error : identifier 'StreamReader' c:\users\user\documents\visual studio 2010\projects\hardware_store\hardware_store\Form1.h Line 204

Error 4 error C2065: 'inData' : undeclared identifier c:\users\user\documents\visual studio 2010\projects\hardware_store\hardware_store\Form1.h 214

Error 5 error C2227: left of '->EndOfStream' must point to class/struct/union/generic type c:\users\user\documents\visual studio 2010\projects\hardware_store\hardware_store\Form1.h Line 214

Error 6 error C1903: unable to recover from previous error(s); stopping compilation c:\users\user\documents\visual studio 2010\projects\hardware_store\hardware_store\Form1.h Line 214

error C2065: 'StreamReader' : undeclared identifier

Add this:

using namespace System::IO;

error C2065: 'inData' : undeclared identifier
error C2227: left of '->EndOfStream' must point to class/struct/union/generic type

These happen because of the StreamReader problem.

The following isn't in your list, but it'll come up:

error C2039: 'searchResult' : is not a member of 'Hardware_Store::Form1'

The member is searchResults, note the plural. Change it in the few places it's not right.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.