Ciao a tutti .. sto' scrivendo un programma e mi servirebbe un aiuto visto che sto' imparando da poco
Questo e' tutto il programma scritto sino ad adesso...il mio problema e', come potete vedere, che nn stampa "titolo" nella prima colonna della prima riga: array<String^>^riga0 = {titolo,"01/01/2009","01/01/2010"};codice:#pragma once #include "stdlib.h" #include "iostream" #include "fstream" #include "string" using namespace std; namespace Tabellone { 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> /// Riepilogo per Form1 /// /// AVVISO: se si modifica il nome della classe, sarà necessario modificare la /// proprietà 'Nome file di risorse' relativa allo strumento Compilatore di risorse gestite /// associato a tutti i file RESX da cui dipende la classe. In caso contrario, /// le finestre di progettazione non saranno in grado di interagire correttamente con le /// risorse localizzate associate al form. /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: aggiungere qui il codice del costruttore. // } protected: /// <summary> /// Liberare le risorse in uso. /// </summary> ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::DataGridView^ dataGridView1; private: System::Windows::Forms::MenuStrip^ menuStrip1; private: System::Windows::Forms::ToolStripMenuItem^ menuToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ apriToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ salvaToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ esciToolStripMenuItem; private: System::Windows::Forms::DataGridViewTextBoxColumn^ Column1; private: System::Windows::Forms::DataGridViewTextBoxColumn^ Column2; private: System::Windows::Forms::DataGridViewTextBoxColumn^ Column3; protected: private: /// <summary> /// Variabile di progettazione necessaria. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Metodo necessario per il supporto della finestra di progettazione. Non modificare /// il contenuto del metodo con l'editor di codice. /// </summary> void InitializeComponent(void) { System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid)); this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView()); this->Column1 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->Column2 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->Column3 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip()); this->menuToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->apriToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->salvaToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->esciToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView1))->BeginInit(); this->menuStrip1->SuspendLayout(); this->SuspendLayout(); // // dataGridView1 // this->dataGridView1->AccessibleDescription = nullptr; this->dataGridView1->AccessibleName = nullptr; this->dataGridView1->AllowUserToResizeColumns = false; this->dataGridView1->AllowUserToResizeRows = false; resources->ApplyResources(this->dataGridView1, L"dataGridView1"); this->dataGridView1->BackgroundImage = nullptr; this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize; this->dataGridView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(3) {this->Column1, this->Column2, this->Column3}); this->dataGridView1->Font = nullptr; this->dataGridView1->Name = L"dataGridView1"; this->dataGridView1->RowHeadersVisible = false; // // Column1 // resources->ApplyResources(this->Column1, L"Column1"); this->Column1->Name = L"Column1"; this->Column1->Resizable = System::Windows::Forms::DataGridViewTriState::False; // // Column2 // resources->ApplyResources(this->Column2, L"Column2"); this->Column2->Name = L"Column2"; this->Column2->Resizable = System::Windows::Forms::DataGridViewTriState::False; // // Column3 // resources->ApplyResources(this->Column3, L"Column3"); this->Column3->Name = L"Column3"; this->Column3->Resizable = System::Windows::Forms::DataGridViewTriState::False; // // menuStrip1 // this->menuStrip1->AccessibleDescription = nullptr; this->menuStrip1->AccessibleName = nullptr; resources->ApplyResources(this->menuStrip1, L"menuStrip1"); this->menuStrip1->BackgroundImage = nullptr; this->menuStrip1->Font = nullptr; this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) {this->menuToolStripMenuItem}); this->menuStrip1->Name = L"menuStrip1"; // // menuToolStripMenuItem // this->menuToolStripMenuItem->AccessibleDescription = nullptr; this->menuToolStripMenuItem->AccessibleName = nullptr; resources->ApplyResources(this->menuToolStripMenuItem, L"menuToolStripMenuItem"); this->menuToolStripMenuItem->BackgroundImage = nullptr; this->menuToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->apriToolStripMenuItem, this->salvaToolStripMenuItem, this->esciToolStripMenuItem}); this->menuToolStripMenuItem->Name = L"menuToolStripMenuItem"; this->menuToolStripMenuItem->ShortcutKeyDisplayString = nullptr; // // apriToolStripMenuItem // this->apriToolStripMenuItem->AccessibleDescription = nullptr; this->apriToolStripMenuItem->AccessibleName = nullptr; resources->ApplyResources(this->apriToolStripMenuItem, L"apriToolStripMenuItem"); this->apriToolStripMenuItem->BackgroundImage = nullptr; this->apriToolStripMenuItem->Name = L"apriToolStripMenuItem"; this->apriToolStripMenuItem->ShortcutKeyDisplayString = nullptr; // // salvaToolStripMenuItem // this->salvaToolStripMenuItem->AccessibleDescription = nullptr; this->salvaToolStripMenuItem->AccessibleName = nullptr; resources->ApplyResources(this->salvaToolStripMenuItem, L"salvaToolStripMenuItem"); this->salvaToolStripMenuItem->BackgroundImage = nullptr; this->salvaToolStripMenuItem->Name = L"salvaToolStripMenuItem"; this->salvaToolStripMenuItem->ShortcutKeyDisplayString = nullptr; // // esciToolStripMenuItem // this->esciToolStripMenuItem->AccessibleDescription = nullptr; this->esciToolStripMenuItem->AccessibleName = nullptr; resources->ApplyResources(this->esciToolStripMenuItem, L"esciToolStripMenuItem"); this->esciToolStripMenuItem->BackgroundImage = nullptr; this->esciToolStripMenuItem->Name = L"esciToolStripMenuItem"; this->esciToolStripMenuItem->ShortcutKeyDisplayString = nullptr; this->esciToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::esciToolStripMenuItem_Click); // // Form1 // this->AccessibleDescription = nullptr; this->AccessibleName = nullptr; resources->ApplyResources(this, L"$this"); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->BackgroundImage = nullptr; this->Controls->Add(this->dataGridView1); this->Controls->Add(this->menuStrip1); this->Font = nullptr; this->Icon = nullptr; this->MainMenuStrip = this->menuStrip1; this->MaximizeBox = false; this->Name = L"Form1"; this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView1))->EndInit(); this->menuStrip1->ResumeLayout(false); this->menuStrip1->PerformLayout(); this->ResumeLayout(false); this->PerformLayout(); } void toRead() { /* String^letturaCampo; ifstream fileDaLeggere("Dati.txt",ios::in); while(!fileDaLeggere.eof()) { getline(fileDaLeggere,letturaCampo); } fileDaLeggere.close(); */ /*String^titolo; ifstream infile("Dati.txt",ios::in); while(infile.good()) titolo;*/ } void toInsertDataGridView1() { String^titolo; ifstream infile("Dati.txt",ios::in); while(infile.good()) titolo; array<String^>^riga0 = {titolo,"01/01/2009","01/01/2010"}; array<String^>^riga1 = {"Spot 2","02/02/2009","02/02/2010"}; array<String^>^riga2 = {"Spot 3","03/03/2009","03/03/2010"}; { DataGridViewRowCollection^ riga = this->dataGridView1->Rows; riga->Add(riga0); riga->Add(riga1); riga->Add(riga2); } { DataGridViewColumnCollection^ columns = this->dataGridView1->Columns; columns[0]->DisplayIndex = 0; columns[1]->DisplayIndex = 1; columns[2]->DisplayIndex = 2; } } #pragma endregion private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { //toRead(); toInsertDataGridView1(); } private: System::Void esciToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { exit(0); } }; }
Come devo fare per prendere del testo da un file txt e farlo stampare nella colonna?
Perche' vorrei fare in modo che "titolo"-"data inizio" - "data fine" vengano salvati in un txt e poi sempre con il programma questo file txt deve essere letto e i valori inseriti nelle rispettive colonne...qualcuno sa' aiutarmi xke sto' uscendo pazzo? Tnx!!

Rispondi quotando