Hi everyone!

I would like to know how to show my Form21 from a click on a button in Form1 I used this code here:

#include "Form21.h"
///
Form21 ^maForm2 = gcnew Form21();
maForm21->Show();

I do not know why it does not work yet I found it in FAQC + + / CLR

it shows me these errors:

1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(526): error C2065: 'Form21' : identificateur non déclaré
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(526): error C2065: 'maForm2' : identificateur non déclaré
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(526): error C2061: erreur de syntaxe : identificateur 'Form21'
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(527): error C2065: 'maForm2' : identificateur non déclaré
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(527): error C2227: la partie gauche de '->Show' doit pointer vers un type class/struct/union/générique
1>          le type est ''unknown-type''
========== Génération : 0 a réussi, 1 a échoué, 1 mis à jour, 0 a été ignoré 

Thank you so much in advance

Dani AI

Generated

Quick diagnosis: the build errors are a classic header/name/circular-include problem rather than a WinForms magic issue. Form21.h in your thread actually declares a different class (Form2) and also includes Form1.h while Form1.h includes Form21.h. That both hides the Form21 type and creates upstream syntax failures (the compiler then chokes on things like vector and string). already pointed out the missing Form21, and asked for the header because the circular include is the likely root cause.

Concrete fixes to apply (in order):

  • Make the header and class names match. Either rename the class to Form21 or rename the file to match the class. Consistency here matters.
  • Break the circular include. Remove #include "Form1.h" from Form21.h. If Form21 only needs a pointer/reference to Form1, forward-declare Form1 in the same namespace instead of including the header:
// put this in Form21.h (same namespace as your forms)
namespace interfaceProject { ref class Form1; }

Include Form1.h only in Form21.cpp when you need Form1's implementation. Conversely, keep including Form21.h where you gcnew the other form so the full type is available there.

  • Fix any mismatched braces/extra } in Form21.h (class should end with }; then close the namespace with }). Use Visual Studio’s brace-matching/collapse to find the stray brace.

Extra tips: watch for simple typos when calling the instance (variable name must match the declaration), and consider moving non-designer logic/event-handler bodies into .cpp files to reduce header dependencies. After correcting the header/class name and removing the circular include, do a Clean + Rebuild — the cascade of “unknown type” and vector errors should disappear and Form1 will be able to create and Show the other form normally.

Recommended Answers

All 8 Replies

post Form21.h

The error message indicates you have not implemented a Form21 class.

@ ddanbe: this is Form1.h

#pragma once
#include "tinyxml.h"
#include <string>
#include <vector>
#include <iostream>
#include "ConnectedComponentSearch1.h"
#include "ReadTestersResourcesXML.h"
#include "ReadTestersResourcesXML.h"
#include "ReadXMLTestersResources.h"
#include "ConnectedComponent.h"
#include "ReadEnvironmentXML1.h"
#include "crerxmlfichier1.h"
#include <sstream>
#include "msclr\marshal_cppstd.h"
#include"TestComponentsGainsVsNodesPlacement.h"
#include "Form21.h"
using namespace std;
namespace interfaceProject {

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
    using namespace System::IO;
    using namespace System::Runtime::InteropServices;

    /// <summary>
    /// Description résumée de Form1
    /// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
         Form1()
      : Form()
   {

      //This call is required by the Windows Form Designer.
      InitializeComponent();

      //Add any initialization after the InitializeComponent() call
   }

    protected:
        /// <summary>
        /// Nettoyage des ressources utilisées.
        /// </summary>
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::Label^  L_NodesProvidedResources;
    protected: 
    private: System::Windows::Forms::Label^  L_TestersRequiredResources;
    private: System::Windows::Forms::DataGridView^  dataGridView1;
    private: System::Windows::Forms::DataGridView^  dataGridView2;
    private: System::Windows::Forms::Panel^  P_panelLodGain;

    private: System::Windows::Forms::Button^  B_LoadNode;
    private: System::Windows::Forms::Button^  B_LoadTest;
    private: System::Windows::Forms::Label^  l_gain;
    private: System::Windows::Forms::Button^  B_Load_Gain_Matrix;

    private: System::Windows::Forms::DataGridView^  dataGridView3;
    private: System::Windows::Forms::Button^  B_GecodeSolver;
    private: System::Windows::Forms::Button^  B_ShowResults;
    private: System::Windows::Forms::Button^  B_GenerateTestPlan;
    private: System::Windows::Forms::Button^  B_Quit;







    private:
        /// <summary>
        /// Variable nécessaire au concepteur.
        /// </summary>
        System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
        /// <summary>
        /// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
        /// le contenu de cette méthode avec l'éditeur de code.
        /// </summary>
        void InitializeComponent(void)
        {
            this->L_NodesProvidedResources = (gcnew System::Windows::Forms::Label());
            this->L_TestersRequiredResources = (gcnew System::Windows::Forms::Label());
            this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
            this->dataGridView2 = (gcnew System::Windows::Forms::DataGridView());
            this->P_panelLodGain = (gcnew System::Windows::Forms::Panel());
            this->l_gain = (gcnew System::Windows::Forms::Label());
            this->B_Load_Gain_Matrix = (gcnew System::Windows::Forms::Button());
            this->dataGridView3 = (gcnew System::Windows::Forms::DataGridView());
            this->B_LoadNode = (gcnew System::Windows::Forms::Button());
            this->B_LoadTest = (gcnew System::Windows::Forms::Button());
            this->B_GecodeSolver = (gcnew System::Windows::Forms::Button());
            this->B_ShowResults = (gcnew System::Windows::Forms::Button());
            this->B_GenerateTestPlan = (gcnew System::Windows::Forms::Button());
            this->B_Quit = (gcnew System::Windows::Forms::Button());
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView1))->BeginInit();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView2))->BeginInit();
            this->P_panelLodGain->SuspendLayout();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView3))->BeginInit();
            this->SuspendLayout();
            // 
            // L_NodesProvidedResources
            // 
            this->L_NodesProvidedResources->AutoSize = true;
            this->L_NodesProvidedResources->Font = (gcnew System::Drawing::Font(L"Times New Roman", 11.25F, static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Italic)), 
                System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
            this->L_NodesProvidedResources->Location = System::Drawing::Point(61, 35);
            this->L_NodesProvidedResources->Name = L"L_NodesProvidedResources";
            this->L_NodesProvidedResources->Size = System::Drawing::Size(184, 18);
            this->L_NodesProvidedResources->TabIndex = 0;
            this->L_NodesProvidedResources->Text = L"Nodes Provided Resources: ";
            // 
            // L_TestersRequiredResources
            // 
            this->L_TestersRequiredResources->AutoSize = true;
            this->L_TestersRequiredResources->Font = (gcnew System::Drawing::Font(L"Times New Roman", 11.25F, static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Italic)), 
                System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
            this->L_TestersRequiredResources->Location = System::Drawing::Point(425, 35);
            this->L_TestersRequiredResources->Name = L"L_TestersRequiredResources";
            this->L_TestersRequiredResources->Size = System::Drawing::Size(187, 18);
            this->L_TestersRequiredResources->TabIndex = 1;
            this->L_TestersRequiredResources->Text = L"Testers Required Resources:";
            this->L_TestersRequiredResources->Click += gcnew System::EventHandler(this, &Form1::L_TestersRequiredResources_Click);
            // 
            // dataGridView1
            // 
            this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
            this->dataGridView1->Location = System::Drawing::Point(33, 65);
            this->dataGridView1->Name = L"dataGridView1";
            this->dataGridView1->Size = System::Drawing::Size(230, 123);
            this->dataGridView1->TabIndex = 2;
            this->dataGridView1->CellContentClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &Form1::dataGridView1_CellContentClick);
            // 
            // dataGridView2
            // 
            this->dataGridView2->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
            this->dataGridView2->Location = System::Drawing::Point(410, 65);
            this->dataGridView2->Name = L"dataGridView2";
            this->dataGridView2->Size = System::Drawing::Size(240, 123);
            this->dataGridView2->TabIndex = 3;
            this->dataGridView2->CellContentClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &Form1::dataGridView2_CellContentClick);
            // 
            // P_panelLodGain
            // 
            this->P_panelLodGain->Controls->Add(this->l_gain);
            this->P_panelLodGain->Controls->Add(this->B_Load_Gain_Matrix);
            this->P_panelLodGain->Controls->Add(this->dataGridView3);
            this->P_panelLodGain->Location = System::Drawing::Point(33, 258);
            this->P_panelLodGain->Name = L"P_panelLodGain";
            this->P_panelLodGain->Size = System::Drawing::Size(617, 123);
            this->P_panelLodGain->TabIndex = 4;
            // 
            // l_gain
            // 
            this->l_gain->AutoSize = true;
            this->l_gain->Font = (gcnew System::Drawing::Font(L"Times New Roman", 11.25F, static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Italic)), 
                System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
            this->l_gain->Location = System::Drawing::Point(198, 21);
            this->l_gain->Name = L"l_gain";
            this->l_gain->Size = System::Drawing::Size(74, 18);
            this->l_gain->TabIndex = 2;
            this->l_gain->Text = L"Gain (i,j)=";
            // 
            // B_Load_Gain_Matrix
            // 
            this->B_Load_Gain_Matrix->Font = (gcnew System::Drawing::Font(L"Times New Roman", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->B_Load_Gain_Matrix->Location = System::Drawing::Point(155, 57);
            this->B_Load_Gain_Matrix->Name = L"B_Load_Gain_Matrix";
            this->B_Load_Gain_Matrix->Size = System::Drawing::Size(157, 23);
            this->B_Load_Gain_Matrix->TabIndex = 1;
            this->B_Load_Gain_Matrix->Text = L"Load_Gain_Matrix";
            this->B_Load_Gain_Matrix->UseVisualStyleBackColor = true;
            this->B_Load_Gain_Matrix->Click += gcnew System::EventHandler(this, &Form1::B_Load_Gain_Matrix_Click);
            // 
            // dataGridView3
            // 
            this->dataGridView3->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
            this->dataGridView3->Location = System::Drawing::Point(374, 3);
            this->dataGridView3->Name = L"dataGridView3";
            this->dataGridView3->Size = System::Drawing::Size(240, 117);
            this->dataGridView3->TabIndex = 0;
            this->dataGridView3->CellContentClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &Form1::dataGridView3_CellContentClick);
            // 
            // B_LoadNode
            // 
            this->B_LoadNode->Font = (gcnew System::Drawing::Font(L"Times New Roman", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->B_LoadNode->Location = System::Drawing::Point(105, 212);
            this->B_LoadNode->Name = L"B_LoadNode";
            this->B_LoadNode->Size = System::Drawing::Size(75, 23);
            this->B_LoadNode->TabIndex = 5;
            this->B_LoadNode->Text = L"Load";
            this->B_LoadNode->UseVisualStyleBackColor = true;
            this->B_LoadNode->Click += gcnew System::EventHandler(this, &Form1::B_LoadNode_Click);
            // 
            // B_LoadTest
            // 
            this->B_LoadTest->Font = (gcnew System::Drawing::Font(L"Times New Roman", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->B_LoadTest->Location = System::Drawing::Point(497, 212);
            this->B_LoadTest->Name = L"B_LoadTest";
            this->B_LoadTest->Size = System::Drawing::Size(75, 23);
            this->B_LoadTest->TabIndex = 6;
            this->B_LoadTest->Text = L"Load";
            this->B_LoadTest->UseVisualStyleBackColor = true;
            this->B_LoadTest->Click += gcnew System::EventHandler(this, &Form1::B_LoadTest_Click);
            // 
            // B_GecodeSolver
            // 
            this->B_GecodeSolver->Font = (gcnew System::Drawing::Font(L"Times New Roman", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->B_GecodeSolver->Location = System::Drawing::Point(54, 409);
            this->B_GecodeSolver->Name = L"B_GecodeSolver";
            this->B_GecodeSolver->Size = System::Drawing::Size(108, 23);
            this->B_GecodeSolver->TabIndex = 7;
            this->B_GecodeSolver->Text = L"Gecode Solver";
            this->B_GecodeSolver->UseVisualStyleBackColor = true;
            this->B_GecodeSolver->Click += gcnew System::EventHandler(this, &Form1::B_GecodeSolver_Click);
            // 
            // B_ShowResults
            // 
            this->B_ShowResults->Font = (gcnew System::Drawing::Font(L"Times New Roman", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->B_ShowResults->Location = System::Drawing::Point(198, 409);
            this->B_ShowResults->Name = L"B_ShowResults";
            this->B_ShowResults->Size = System::Drawing::Size(107, 23);
            this->B_ShowResults->TabIndex = 8;
            this->B_ShowResults->Text = L"Show Results";
            this->B_ShowResults->UseVisualStyleBackColor = true;
            this->B_ShowResults->Click += gcnew System::EventHandler(this, &Form1::B_ShowResults_Click);
            // 
            // B_GenerateTestPlan
            // 
            this->B_GenerateTestPlan->Font = (gcnew System::Drawing::Font(L"Times New Roman", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->B_GenerateTestPlan->Location = System::Drawing::Point(348, 409);
            this->B_GenerateTestPlan->Name = L"B_GenerateTestPlan";
            this->B_GenerateTestPlan->Size = System::Drawing::Size(142, 23);
            this->B_GenerateTestPlan->TabIndex = 9;
            this->B_GenerateTestPlan->Text = L"Generate Test Plan";
            this->B_GenerateTestPlan->UseVisualStyleBackColor = true;
            this->B_GenerateTestPlan->Click += gcnew System::EventHandler(this, &Form1::B_GenerateTestPlan_Click);
            // 
            // B_Quit
            // 
            this->B_Quit->Font = (gcnew System::Drawing::Font(L"Times New Roman", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->B_Quit->Location = System::Drawing::Point(537, 409);
            this->B_Quit->Name = L"B_Quit";
            this->B_Quit->Size = System::Drawing::Size(75, 23);
            this->B_Quit->TabIndex = 10;
            this->B_Quit->Text = L"Quit";
            this->B_Quit->UseVisualStyleBackColor = true;
            this->B_Quit->Click += gcnew System::EventHandler(this, &Form1::B_Quit_Click);
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(679, 455);
            this->Controls->Add(this->B_Quit);
            this->Controls->Add(this->B_GenerateTestPlan);
            this->Controls->Add(this->B_ShowResults);
            this->Controls->Add(this->B_GecodeSolver);
            this->Controls->Add(this->B_LoadTest);
            this->Controls->Add(this->B_LoadNode);
            this->Controls->Add(this->P_panelLodGain);
            this->Controls->Add(this->dataGridView2);
            this->Controls->Add(this->dataGridView1);
            this->Controls->Add(this->L_TestersRequiredResources);
            this->Controls->Add(this->L_NodesProvidedResources);
            this->Name = L"Form1";
            this->Text = L"Gecode";
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView1))->EndInit();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView2))->EndInit();
            this->P_panelLodGain->ResumeLayout(false);
            this->P_panelLodGain->PerformLayout();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView3))->EndInit();
            this->ResumeLayout(false);
            this->PerformLayout();

        }


#pragma endregion
        //this->StartPosition = FormStartPosition::CenterScreen;
    private: System::Void L_TestersRequiredResources_Click(System::Object^  sender, System::EventArgs^  e) {
             }
    private: System::Void dataGridView1_CellContentClick(System::Object^  sender, System::Windows::Forms::DataGridViewCellEventArgs^  e) {
                 dataGridView1->AutoResizeColumnHeadersHeight();

      // Resize all the row heights to fit the contents of all non-header cells.
     dataGridView1->AutoResizeRows(
            DataGridViewAutoSizeRowsMode::AllCellsExceptHeaders);
         // Set the column header names.


             }
    private: System::Void B_LoadNode_Click(System::Object^  sender, System::EventArgs^  e) {
 dataGridView1->ColumnCount = 4;
      dataGridView1->ColumnHeadersVisible = true;

      // Set the column header style.
      DataGridViewCellStyle ^ columnHeaderStyle = gcnew DataGridViewCellStyle;
      columnHeaderStyle->BackColor = Color::Aqua;
      columnHeaderStyle->Font = gcnew System::Drawing::Font( "Verdana",10,FontStyle::Bold );
      dataGridView1->ColumnHeadersDefaultCellStyle = columnHeaderStyle;

      // Set the column header names.
      dataGridView1->Columns[ 0 ]->Name = "";
      dataGridView1->Columns[ 1 ]->Name = "RAM";
      dataGridView1->Columns[ 2 ]->Name = "CPU";
      dataGridView1->Columns[ 3 ]->Name = "BAT";

      // Populate the rows.

    //  Console::WriteLine(f);
        ReadEnvironmentXML1 reader;
    //ReadTestersResourcesXML reader1;
    int size=reader.lire_size();
    vector<string> myNodes= reader.lire_Nodes();
    vector<vector<int>> edgs=reader.lire_Links();
    vector<int> capacitRam= reader.lire_RAM();
    vector<int> capacitBat = reader.lire_BAT( ) ;
    vector<int> capacitCPU= reader.lire_CPU();
    vector<vector<int>>  lnk_val = reader.lire_Links_val();
    vector<int> maxp= reader.lire_MaxP();

    while(!myNodes.empty())
    {
          int j =0;
        string f=myNodes[j];
      String^ Cell0= gcnew String(f.c_str());
        myNodes.erase( myNodes.begin());

       int Number=capacitRam[j];
       string g = static_cast<ostringstream*>( &(ostringstream() << Number) )->str();
       String^ Cell1= gcnew String(g.c_str());
       capacitRam.erase(capacitRam.begin());

        int Number1=capacitCPU[j];
      string h = static_cast<ostringstream*>( &(ostringstream() << Number1) )->str();
       String^ Cell2= gcnew String(h.c_str());
       capacitCPU.erase(capacitCPU.begin());

      int Number2=capacitBat[j];
      string r = static_cast<ostringstream*>( &(ostringstream() << Number2) )->str();
      String^ Cell3= gcnew String(r.c_str());
      capacitBat.erase(capacitBat.begin());

    array<String^>^row1 = gcnew array<String^>{
         Cell0 ,Cell1, Cell2, Cell3
      };
     array<Object^>^rows = {row1};
      System::Collections::IEnumerator^ myEnum = rows->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         array<String^>^rowArray = safe_cast<array<String^>^>(myEnum->Current);      
         dataGridView1->Rows->Add( rowArray );
      }

    }           

             }
private: System::Void B_LoadTest_Click(System::Object^  sender, System::EventArgs^  e) {

dataGridView2->ColumnCount = 4;
      dataGridView2->ColumnHeadersVisible = true;

      // Set the column header style.
      DataGridViewCellStyle ^ columnHeaderStyle = gcnew DataGridViewCellStyle;
      columnHeaderStyle->BackColor = Color::Aqua;
      columnHeaderStyle->Font = gcnew System::Drawing::Font( "Verdana",10,FontStyle::Bold );
      dataGridView2->ColumnHeadersDefaultCellStyle = columnHeaderStyle;

      // Set the column header names.
      dataGridView2->Columns[ 0 ]->Name = "";
      dataGridView2->Columns[ 1 ]->Name = "RAM";
      dataGridView2->Columns[ 2 ]->Name = "CPU";
      dataGridView2->Columns[ 3 ]->Name = "BAT";

      // Populate the rows.

    ReadXMLTestersResources reader1;
    int size1=reader1.lire_size();
    vector<string>MyTesters= reader1.Lire_testeur();
    vector<int> capacitRam1= reader1.lire_RAM();
    vector<int> capacitCPU1= reader1.lire_CPU( );
    vector<int> capacitBat1 = reader1.lire_BAT( );
    while(!MyTesters.empty())
    {
          int j =0;
        string f=MyTesters[j];
      String^ Cell0= gcnew String(f.c_str());
        MyTesters.erase( MyTesters.begin());

       int Number=capacitRam1[j];
       string g = static_cast<ostringstream*>( &(ostringstream() << Number) )->str();
       String^ Cell1= gcnew String(g.c_str());
       capacitRam1.erase(capacitRam1.begin());

        int Number1=capacitCPU1[j];
      string h = static_cast<ostringstream*>( &(ostringstream() << Number1) )->str();
       String^ Cell2= gcnew String(h.c_str());
       capacitCPU1.erase(capacitCPU1.begin());

      int Number2=capacitBat1[j];
      string r = static_cast<ostringstream*>( &(ostringstream() << Number2) )->str();
      String^ Cell3= gcnew String(r.c_str());
      capacitBat1.erase(capacitBat1.begin());

    array<String^>^row1 = gcnew array<String^>{
         Cell0 ,Cell1, Cell2, Cell3
      };
     array<Object^>^rows = {row1};
      System::Collections::IEnumerator^ myEnum = rows->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         array<String^>^rowArray = safe_cast<array<String^>^>(myEnum->Current);      
         dataGridView2->Rows->Add( rowArray );
      }

    }       

         }
private: System::Void B_Load_Gain_Matrix_Click(System::Object^  sender, System::EventArgs^  e) {
             ConnectedComponentSearch1 reader2;
             reader2.init_graph();
    vector<bool> manel=reader2.Breadth_First_Search("N1");
    vector<ConnectedComponent> ala= reader2.CC_calculation();
    reader2.m_edges;
             ReadEnvironmentXML1 reader;
    //ReadTestersResourcesXML reader1;
      int size=reader.lire_size();
    vector<string> myNodes= reader.lire_Nodes();
    vector<vector<int>> edgs=reader.lire_Links();
    vector<int> capacitRam= reader.lire_RAM();
    vector<int> capacitBat = reader.lire_BAT( ) ;
    vector<int> capacitCPU= reader.lire_CPU();
    vector<vector<int>>  lnk_val = reader.lire_Links_val();
    vector<int> maxp= reader.lire_MaxP();

             dataGridView3->ColumnCount =size ;
             dataGridView3->ColumnHeadersVisible = true;

      // Set the column header style.
      DataGridViewCellStyle ^ columnHeaderStyle = gcnew DataGridViewCellStyle;
      columnHeaderStyle->BackColor = Color::Aqua;
      columnHeaderStyle->Font = gcnew System::Drawing::Font( "Verdana",10,FontStyle::Bold );
      dataGridView3->ColumnHeadersDefaultCellStyle = columnHeaderStyle;

      // Set the column header names.

      for (int i =0;i<reader2.m_vertices_number;i++)
      {
            string f=reader2.m_vertices[i];
      String^ Cell0= gcnew String(f.c_str());
      dataGridView3->Columns[ i ]->Name = Cell0;
      }


      // Populate the rows.
    int d=0;
    const std::size_t w(100);
     const std::size_t h(100);
     vector<vector<int>>GainMatrix;
    for(unsigned int i(0); i < h; ++i)
      GainMatrix.emplace_back(std::vector<int>(w));
         int pied =-1;
        for (int i =0; i <ala.size(); i++ )
        { 
            for (int j=0; j<ala[i].m_nodes.size(); j++)  
            {
                pied++;
                string f=ala[i].m_nodes[j];
                cout<<"f="<<f<<endl;
                vector<int>naoufal = reader2.distance_calculation(ala[i], f);

                for( int a =0; a <naoufal.size(); a++ )
                {
                int Number=naoufal[a];
                string g = static_cast<ostringstream*>( &(ostringstream() << Number) )->str();
                String^ Cell2= gcnew String(g.c_str());

                array<String^>^row1 = gcnew array<String^>{
                Cell2
                    };
                    array<Object^>^rows = {row1};
                      System::Collections::IEnumerator^ myEnum = rows->GetEnumerator();
                      while ( myEnum->MoveNext() )
                      {
                         array<String^>^rowArray = safe_cast<array<String^>^>(myEnum->Current);      
                         dataGridView3->Rows->Add( rowArray );
                      }

                 }




            }
        }



         }
private: System::Void B_GecodeSolver_Click(System::Object^  sender, System::EventArgs^  e) {
         }
private: System::Void B_ShowResults_Click(System::Object^  sender, System::EventArgs^  e) {
            //this->Hide();
            // TestComponentsGainsVsNodesPlacement ^maForm2 = gcnew TestComponentsGainsVsNodesPlacement();
                //maForm2->Show();

             Form21 ^maForm2 = gcnew Form21();
             maForm2->Show();

         }
private: System::Void B_GenerateTestPlan_Click(System::Object^  sender, System::EventArgs^  e) {
             // Demande de confirmation
    if (MessageBox::Show(this, 
            "Sauvegarder le document?",
            "Sauvegarde", 
            MessageBoxButtons::YesNo,
            MessageBoxIcon::Question) == Windows::Forms::DialogResult::No)
        return;

             int m=5;
             int n=5;
             crerxmlfichier1 writer;
             writer.write_simple_doc2(n,m);
         }
private: System::Void B_Quit_Click(System::Object^  sender, System::EventArgs^  e) {

             Close();
         }
private: System::Void dataGridView2_CellContentClick(System::Object^  sender, System::Windows::Forms::DataGridViewCellEventArgs^  e) {
             dataGridView2->AutoResizeColumnHeadersHeight();

      // Resize all the row heights to fit the contents of all non-header cells.
     dataGridView2->AutoResizeRows(
            DataGridViewAutoSizeRowsMode::AllCellsExceptHeaders);

         }

private: System::Void dataGridView3_CellContentClick(System::Object^  sender, System::Windows::Forms::DataGridViewCellEventArgs^  e) {

             dataGridView3->AutoResizeColumnHeadersHeight();

      // Resize all the row heights to fit the contents of all non-header cells.
     dataGridView3->AutoResizeRows(
            DataGridViewAutoSizeRowsMode::AllCellsExceptHeaders);
         }
};
}

OK, you have implemented a Form1 class, but have you also a Form21 class?

commented: 22222222222222222 +0

i wiill send you also my Form21 because i think i did implemented it also

#pragma once
#include "Form1.h"
#include <vector>
#include <string>

namespace interfaceProject {

    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>
    /// Description résumée de Form2
    /// </summary>
    public ref class Form2 : public System::Windows::Forms::Form
    {
    public:
        Form2()
            : Form()
        {
            InitializeComponent();
            //
            //TODO: ajoutez ici le code du constructeur
            //
        }

    protected:
        /// <summary>
        /// Nettoyage des ressources utilisées.
        /// </summary>
        ~Form2()
        {
            if (components)
            {
                delete components;
            }
        }

    private: System::Windows::Forms::DataGridView^  dataGridView1;
    protected: 

    private:
        /// <summary>
        /// Variable nécessaire au concepteur.
        /// </summary>
        System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
        /// <summary>
        /// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
        /// le contenu de cette méthode avec l'éditeur de code.
        /// </summary>
        void InitializeComponent(void)
        {
            this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView1))->BeginInit();
            this->SuspendLayout();
            // 
            // dataGridView1
            // 
            this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
            this->dataGridView1->Location = System::Drawing::Point(12, 12);
            this->dataGridView1->Name = L"dataGridView1";
            this->dataGridView1->Size = System::Drawing::Size(524, 150);
            this->dataGridView1->TabIndex = 1;
            this->dataGridView1->CellContentClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &Form2::dataGridView1_CellContentClick);
            // 
            // Form2
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(566, 262);
            this->Controls->Add(this->dataGridView1);
            this->Name = L"Form2";
            this->Text = L"Form2";
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView1))->EndInit();
            this->ResumeLayout(false);

        }
#pragma endregion
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

             }
    private: System::Void dataGridView1_CellContentClick(System::Object^  sender, System::Windows::Forms::DataGridViewCellEventArgs^  e) {
            dataGridView1->AutoResizeColumnHeadersHeight();

      // Resize all the row heights to fit the contents of all non-header cells.
     dataGridView1->AutoResizeRows(
            DataGridViewAutoSizeRowsMode::AllCellsExceptHeaders);
         // Set the column header names.

     // Create an unbound DataGridView by declaring a column count.
      dataGridView1->ColumnCount = 4;
      dataGridView1->ColumnHeadersVisible = true;

      // Set the column header style.
      DataGridViewCellStyle ^ columnHeaderStyle = gcnew DataGridViewCellStyle;
      columnHeaderStyle->BackColor = Color::Aqua;
      columnHeaderStyle->Font = gcnew System::Drawing::Font( "Verdana",10,FontStyle::Bold );
      dataGridView1->ColumnHeadersDefaultCellStyle = columnHeaderStyle;

      // Set the column header names.
      dataGridView1->Columns[ 0 ]->Name = "Recipe";
      dataGridView1->Columns[ 1 ]->Name = "Category";
      dataGridView1->Columns[ 2 ]->Name = "Main Ingredients";
      dataGridView1->Columns[ 3 ]->Name = "Rating";

      // Populate the rows.
      array<String^>^row1 = gcnew array<String^>{
         "Meatloaf","Main Dish","ground beef","**"
      };
      array<String^>^row2 = gcnew array<String^>{
         "Key Lime Pie","Dessert","lime juice, evaporated milk","****"
      };
      array<String^>^row3 = gcnew array<String^>{
         "Orange-Salsa Pork Chops","Main Dish","pork chops, salsa, orange juice","****"
      };
      array<String^>^row4 = gcnew array<String^>{
         "Black Bean and Rice Salad","Salad","black beans, brown rice","****"
      };
      array<String^>^row5 = gcnew array<String^>{
         "Chocolate Cheesecake","Dessert","cream cheese","***"
      };
      array<String^>^row6 = gcnew array<String^>{
         "Black Bean Dip","Appetizer","black beans, sour cream","***"
      };
      array<Object^>^rows = {row1,row2,row3,row4,row5,row6};
      System::Collections::IEnumerator^ myEnum = rows->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         array<String^>^rowArray = safe_cast<array<String^>^>(myEnum->Current);
         dataGridView1->Rows->Add( rowArray );
      }
             }
             }
    };
}

when ijust put the include (#include "Form21.h") it shows me these errors :

1>------ Début de la génération : Projet : interfaceProject, Configuration : Debug Win32 ------
1>  interfaceProject.cpp
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form21.h(139): error C2143: erreur de syntaxe : absence de ';' avant '}'
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form21.h(140): error C2059: erreur de syntaxe : '}'
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form21.h(140): error C2143: erreur de syntaxe : absence de ';' avant '}'
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form21.h(140): error C2059: erreur de syntaxe : '}'
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(333): error C2065: 'vector' : identificateur non déclaré
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(333): error C2065: 'string' : identificateur non déclaré
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(333): error C2065: 'myNodes' : identificateur non déclaré
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(334): error C2065: 'vector' : identificateur non déclaré
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(334): error C2065: 'vector' : identificateur non déclaré
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(334): error C2062: type 'int' inattendu
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(335): error C2065: 'vector' : identificateur non déclaré
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(335): error C2062: type 'int' inattendu
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(336): error C2065: 'vector' : identificateur non déclaré
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(336): error C2062: type 'int' inattendu
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(337): error C2065: 'vector' : identificateur non déclaré
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(337): error C2062: type 'int' inattendu
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(338): error C2065: 'vector' : identificateur non déclaré
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(338): error C2065: 'vector' : identificateur non déclaré
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(338): error C2062: type 'int' inattendu
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(339): error C2065: 'vector' : identificateur non déclaré
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(339): error C2062: type 'int' inattendu
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(341): error C2065: 'myNodes' : identificateur non déclaré
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(341): error C2228: la partie gauche de '.empty' doit avoir un class/struct/union
1>          le type est ''unknown-type''
1>c:\visual studio 2010\projects\interfaceproject\interfaceproject\Form1.h(341): fatal error C1903: impossible de récupérer à partir des erreurs précédentes ; arrêt de la compilation
========== Génération : 0 a réussi, 1 a échoué, 1 mis à jour, 0 a été ignoré ==========

and when i remove it form1 works fine!!!!! is that normal ????????

Yes, but I never see Form21(vingt et un) I see Form2(deux) as a class. There must be a name confusion somewhere I guess.

thank you for your help it is just like you said need an implementation for the form21.h , ineed just to mre focus on my work , thank you again have a good day :)

You could consider marking this thread as solved. Happy coding :)

commented: 123455678 +0
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.