Help with button function

Hello i need help creating a button that will save whatever the user is typing into an XML file so then when next time they open it. Here is what i have working right now

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220

#pragma once

namespace Organizer 
{
   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::Xml;

   /// <summary>

   /// Summary for Form1

   ///

   /// WARNING: If you change the name of this class, you will need to change the

   ///          'Resource File Name' property for the managed resource compiler tool

   ///          associated with all .resx files this class depends on. Otherwise,

   ///          the designers will not be able to interact properly with localized

   ///          resources associated with this form.

   /// </summary>

   public ref class Form1 : public System::Windows::Forms::Form

   {

   public:

      Form1(void)

      {

         InitializeComponent();

         //

         //TODO: Add the constructor code here

         //

      }

   private: System::Windows::Forms::DataGridViewTextBoxColumn^  Item_Name;

   public:

   private: System::Windows::Forms::DataGridViewTextBoxColumn^  Category;

      DataSet ^dsList;
 
   protected:

      /// <summary>

      /// Clean up any resources being used.

      /// </summary>

      ~Form1()

      {

         if (components)

         {

            delete components;

         }

      }

   private: System::Windows::Forms::MenuStrip^  menuStrip1;

   private: System::Windows::Forms::ToolStripMenuItem^  fileToolStripMenuItem;

   private: System::Windows::Forms::ToolStripMenuItem^  exitToolStripMenuItem;

   private: System::Windows::Forms::DataGridView^  MyGrid;

   protected:

   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)

      {
		  this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
		  this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
		  this->exitToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
		  this->MyGrid = (gcnew System::Windows::Forms::DataGridView());
		  this->Item_Name = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
		  this->Category = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
		  this->menuStrip1->SuspendLayout();
		  (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->MyGrid))->BeginInit();
		  this->SuspendLayout();
		  // 
		  // menuStrip1
		  // 
		  this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->fileToolStripMenuItem});
		  this->menuStrip1->Location = System::Drawing::Point(0, 0);
		  this->menuStrip1->Name = L"menuStrip1";
		  this->menuStrip1->Size = System::Drawing::Size(492, 24);
		  this->menuStrip1->TabIndex = 0;
		  this->menuStrip1->Text = L"menuStrip1";
		  // 
		  // fileToolStripMenuItem
		  // 
		  this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->exitToolStripMenuItem});
		  this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem";
		  this->fileToolStripMenuItem->Size = System::Drawing::Size(37, 20);
		  this->fileToolStripMenuItem->Text = L"File";
		  // 
		  // exitToolStripMenuItem
		  // 
		  this->exitToolStripMenuItem->Name = L"exitToolStripMenuItem";
		  this->exitToolStripMenuItem->Size = System::Drawing::Size(92, 22);
		  this->exitToolStripMenuItem->Text = L"Exit";
		  this->exitToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::exitToolStripMenuItem_Click);
		  // 
		  // MyGrid
		  // 
		  this->MyGrid->AllowUserToOrderColumns = true;
		  this->MyGrid->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
		  this->MyGrid->Dock = System::Windows::Forms::DockStyle::Fill;
		  this->MyGrid->Location = System::Drawing::Point(0, 24);
		  this->MyGrid->Name = L"MyGrid";
		  this->MyGrid->Size = System::Drawing::Size(492, 236);
		  this->MyGrid->TabIndex = 1;
		  this->MyGrid->CellContentClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &Form1::MyGrid_CellContentClick);
		  // 
		  // Item_Name
		  // 
		  this->Item_Name->HeaderText = L"Item_Name";
		  this->Item_Name->Name = L"Item_Name";
		  this->Item_Name->ReadOnly = true;
		  // 
		  // Category
		  // 
		  this->Category->HeaderText = L"Category";
		  this->Category->Name = L"Category";
		  this->Category->ReadOnly = true;
		  // 
		  // Form1
		  // 
		  this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
		  this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
		  this->ClientSize = System::Drawing::Size(492, 260);
		  this->Controls->Add(this->MyGrid);
		  this->Controls->Add(this->menuStrip1);
		  this->MainMenuStrip = this->menuStrip1;
		  this->Name = L"Form1";
		  this->Text = L"My Organizer";
		  this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
		  this->menuStrip1->ResumeLayout(false);
		  this->menuStrip1->PerformLayout();
		  (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->MyGrid))->EndInit();
		  this->ResumeLayout(false);
		  this->PerformLayout();

	  }

#pragma endregion

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

             Close ( );

          }

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

            dsList = gcnew DataSet("list");

            this -> dsList -> ReadXml ("Data.xml");

            this -> MyGrid -> DataSource = dsList;

            this -> MyGrid -> DataMember = "item";

          }

private: System::Void MyGrid_CellContentClick(System::Object^  sender, System::Windows::Forms::DataGridViewCellEventArgs^  e) {
		 }
};

}
Last edited on
Topic archived. No new replies allowed.