manel1989 0 Light Poster

Hi everyone!

I have a datagridview and I want to automatically fill it

Let me explain: I have a matrix (gainMatrix) and I want to fill my datagridview by the latter, here is a piece of code that I use for filling:

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 );
                      }

                 }
            }
        }

what I want is to fill all the elements naoufal for example in the first iteration in the first line of the datagridview and this code does not help me, it shows me each element of the vector naoufal in a row :/

I do not know what to do, or is there a method that allows me to do it.????

Thank you very much for your help

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.