Форум программистов, компьютерный форум, киберфорум
C++/CLI Windows Forms
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.54/13: Рейтинг темы: голосов - 13, средняя оценка - 4.54
0 / 0 / 0
Регистрация: 12.04.2012
Сообщений: 20

Потоки: построчно записать в файл информацию из нескольких textBox'ов

20.05.2012, 00:08. Показов 2625. Ответов 1
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Нужно построчно записать в файл информацию из нескольких textBox'ов на форме по нажатию на кнопку. Помогите пожалуйста.

C++
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
#pragma once
 
namespace kyrsProject {
 
    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
    {
    public:
        Form1(void)
        {
            InitializeComponent();
            //
            //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;
    private: System::Windows::Forms::TextBox^  textBox1;
    private: System::Windows::Forms::Label^  label2;
    private: System::Windows::Forms::TextBox^  textBox2;
    private: System::Windows::Forms::Label^  label3;
    private: System::Windows::Forms::ComboBox^  comboBox1;
    private: System::Windows::Forms::TextBox^  textBox3;
    private: System::Windows::Forms::Label^  label4;
    private: System::Windows::Forms::ComboBox^  comboBox2;
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::Button^  button2;
    private: System::Windows::Forms::Label^  label5;
    private: System::Windows::Forms::ComboBox^  comboBox3;
    private: System::Windows::Forms::Label^  label6;
    private: System::Windows::Forms::SaveFileDialog^  saveFileDialog1;
 
 
 
 
 
    protected: 
 
    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->label1 = (gcnew System::Windows::Forms::Label());
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->label2 = (gcnew System::Windows::Forms::Label());
            this->textBox2 = (gcnew System::Windows::Forms::TextBox());
            this->label3 = (gcnew System::Windows::Forms::Label());
            this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
            this->textBox3 = (gcnew System::Windows::Forms::TextBox());
            this->label4 = (gcnew System::Windows::Forms::Label());
            this->comboBox2 = (gcnew System::Windows::Forms::ComboBox());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->button2 = (gcnew System::Windows::Forms::Button());
            this->label5 = (gcnew System::Windows::Forms::Label());
            this->comboBox3 = (gcnew System::Windows::Forms::ComboBox());
            this->label6 = (gcnew System::Windows::Forms::Label());
            this->saveFileDialog1 = (gcnew System::Windows::Forms::SaveFileDialog());
            this->SuspendLayout();
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->ForeColor = System::Drawing::Color::White;
            this->label1->Location = System::Drawing::Point(9, 43);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(142, 13);
            this->label1->TabIndex = 0;
            this->label1->Text = L"Введите тестовый вопрос:";
            // 
            // textBox1
            // 
            this->textBox1->Location = System::Drawing::Point(12, 59);
            this->textBox1->Multiline = true;
            this->textBox1->Name = L"textBox1";
            this->textBox1->Size = System::Drawing::Size(895, 20);
            this->textBox1->TabIndex = 1;
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->ForeColor = System::Drawing::Color::White;
            this->label2->Location = System::Drawing::Point(9, 94);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(268, 13);
            this->label2->TabIndex = 2;
            this->label2->Text = L"Введите время выполнения (для данного вопроса):";
            // 
            // textBox2
            // 
            this->textBox2->Location = System::Drawing::Point(12, 110);
            this->textBox2->Name = L"textBox2";
            this->textBox2->Size = System::Drawing::Size(48, 20);
            this->textBox2->TabIndex = 3;
            // 
            // label3
            // 
            this->label3->AutoSize = true;
            this->label3->ForeColor = System::Drawing::Color::White;
            this->label3->Location = System::Drawing::Point(18, 209);
            this->label3->Name = L"label3";
            this->label3->Size = System::Drawing::Size(67, 13);
            this->label3->TabIndex = 4;
            this->label3->Text = L"Один ответ:";
            this->label3->Visible = false;
            // 
            // comboBox1
            // 
            this->comboBox1->FormattingEnabled = true;
            this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"2", L"3", L"4", L"5"});
            this->comboBox1->Location = System::Drawing::Point(21, 225);
            this->comboBox1->Name = L"comboBox1";
            this->comboBox1->Size = System::Drawing::Size(117, 21);
            this->comboBox1->TabIndex = 5;
            this->comboBox1->Visible = false;
            this->comboBox1->TextChanged += gcnew System::EventHandler(this, &Form1::comboBox1_TextChanged);
            // 
            // textBox3
            // 
            this->textBox3->Location = System::Drawing::Point(90, 110);
            this->textBox3->Name = L"textBox3";
            this->textBox3->Size = System::Drawing::Size(48, 20);
            this->textBox3->TabIndex = 6;
            // 
            // label4
            // 
            this->label4->AutoSize = true;
            this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 15.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(204)));
            this->label4->Location = System::Drawing::Point(65, 110);
            this->label4->Name = L"label4";
            this->label4->Size = System::Drawing::Size(19, 25);
            this->label4->TabIndex = 7;
            this->label4->Text = L":";
            // 
            // comboBox2
            // 
            this->comboBox2->FormattingEnabled = true;
            this->comboBox2->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"2", L"3", L"4", L"5"});
            this->comboBox2->Location = System::Drawing::Point(471, 225);
            this->comboBox2->Name = L"comboBox2";
            this->comboBox2->Size = System::Drawing::Size(121, 21);
            this->comboBox2->TabIndex = 8;
            this->comboBox2->Visible = false;
            this->comboBox2->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox2_SelectedIndexChanged);
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(270, 518);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(155, 38);
            this->button1->TabIndex = 9;
            this->button1->Text = L"Сохранить данные в файл\r\n";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
            // 
            // button2
            // 
            this->button2->Location = System::Drawing::Point(21, 518);
            this->button2->Name = L"button2";
            this->button2->Size = System::Drawing::Size(155, 38);
            this->button2->TabIndex = 10;
            this->button2->Text = L"Обновить форму";
            this->button2->UseVisualStyleBackColor = true;
            this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
            // 
            // label5
            // 
            this->label5->AutoSize = true;
            this->label5->ForeColor = System::Drawing::SystemColors::ControlLightLight;
            this->label5->Location = System::Drawing::Point(468, 209);
            this->label5->Name = L"label5";
            this->label5->Size = System::Drawing::Size(106, 13);
            this->label5->TabIndex = 11;
            this->label5->Text = L"Несколько ответов";
            this->label5->Visible = false;
            // 
            // comboBox3
            // 
            this->comboBox3->FormattingEnabled = true;
            this->comboBox3->Items->AddRange(gcnew cli::array< System::Object^  >(2) {L"Один", L"Несколько"});
            this->comboBox3->Location = System::Drawing::Point(21, 170);
            this->comboBox3->Name = L"comboBox3";
            this->comboBox3->Size = System::Drawing::Size(121, 21);
            this->comboBox3->TabIndex = 12;
            this->comboBox3->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox3_SelectedIndexChanged);
            // 
            // label6
            // 
            this->label6->AutoSize = true;
            this->label6->ForeColor = System::Drawing::SystemColors::ControlLightLight;
            this->label6->Location = System::Drawing::Point(18, 154);
            this->label6->Name = L"label6";
            this->label6->Size = System::Drawing::Size(227, 13);
            this->label6->TabIndex = 13;
            this->label6->Text = L"Сколько может быть правильных ответов\?";
            // 
            // saveFileDialog1
            // 
            this->saveFileDialog1->FileOk += gcnew System::ComponentModel::CancelEventHandler(this, &Form1::saveFileDialog1_FileOk);
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->BackColor = System::Drawing::SystemColors::ControlDarkDark;
            this->ClientSize = System::Drawing::Size(919, 588);
            this->Controls->Add(this->label6);
            this->Controls->Add(this->comboBox3);
            this->Controls->Add(this->label5);
            this->Controls->Add(this->button2);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->comboBox2);
            this->Controls->Add(this->label4);
            this->Controls->Add(this->textBox3);
            this->Controls->Add(this->comboBox1);
            this->Controls->Add(this->label3);
            this->Controls->Add(this->textBox2);
            this->Controls->Add(this->label2);
            this->Controls->Add(this->textBox1);
            this->Controls->Add(this->label1);
            this->Name = L"Form1";
            this->Text = L"Form1";
            this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
            this->ResumeLayout(false);
            this->PerformLayout();
 
        }
#pragma endregion
    private: System::Void comboBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) //comboBox для создания вариантов ответов
             {
                 int anInteger = System::Convert::ToInt32(comboBox1->Text);   //Перевод строки в численное значение
                 for(int i=0; i<anInteger; i++)
                 {
                     TextBox^ t= (TextBox^)this->Controls["textBox"+i.ToString()];  //Массив texBox'ов
                     t=(gcnew System::Windows::Forms::TextBox());
                     t->Location = System::Drawing::Point(37, 260+i*25);
                     t->Size = System::Drawing::Size(400, 20);
                     this->Controls->Add(t);
 
                     RadioButton^ r= (RadioButton^)this->Controls["radioButton"+i.ToString()];
                     r=(gcnew System::Windows::Forms::RadioButton());
                     r->Location = System::Drawing::Point(21, 260+i*25);
                     this->Controls->Add(r);
 
                 }
             }
private: System::Void comboBox2_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) 
         {
             int anInteger1 = System::Convert::ToInt32(comboBox2->Text);   //Перевод строки в численное значение
                 for(int i=0; i<anInteger1; i++)
                 {
                     TextBox^ l= (TextBox^)this->Controls["TextBox"+i.ToString()];
                     l=(gcnew System::Windows::Forms::TextBox());
                     l->Location = System::Drawing::Point(492, 260+i*25);
                     l->Size = System::Drawing::Size(400, 20);
                     this->Controls->Add(l);
 
 
                     CheckBox^ j= (CheckBox^)this->Controls["checkBox"+i.ToString()];  //Массив texBox'ов
                     j=(gcnew System::Windows::Forms::CheckBox());
                     j->Location = System::Drawing::Point(472, 260+i*25);
                     j->Visible = true;
                     j->UseVisualStyleBackColor = true;
                     this->Controls->Add(j);
                 }
         }
 
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
         {
            
         }
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
         }
private: System::Void comboBox3_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) 
         {
             if(comboBox3->SelectedIndex==0)
             {
                 this->comboBox1->Visible = true;
                 this->label3->Visible = true;
             }
             else 
             {
                 this->comboBox2->Visible = true;
                 this->label5->Visible = true; 
             }
         }
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) 
         {
            this->textBox1->Clear();
            this->textBox2->Clear();
            this->textBox3->Clear();
         }
 
};
}
0
Programming
Эксперт
39485 / 9562 / 3019
Регистрация: 12.04.2006
Сообщений: 41,671
Блог
20.05.2012, 00:08
Ответы с готовыми решениями:

Построчно записать информацию в файл и подсчитать количество строк
Помогите решить задачу: Составьте программу, которая создает на диске D: текстовый файл, записывает в него построчно информацию...

Как данные, посылаемые построчно из Arduino по СОМ-порту, записать построчно в текстовый файл?
Программирование для меня - неосновная область работы. Поэтому ищу готовые решения. И меня крепко удивила реакция на форумах на простой...

Как построчно считать и записать информацию в txt
какие есть методы какие методы оптимальны примеры реализаций

1
0 / 0 / 0
Регистрация: 08.03.2014
Сообщений: 3
16.03.2014, 16:05
C++
1
2
3
4
#include <iostream>
#include <fstream>
using namespace std;
using namespace System::IO;
...
C++
1
2
3
StreamWriter^ sw = gcnew StreamWriter("C:\\Учет.txt",ios::ate|ios::out);//открыли файл для добавления информации в конец и записи
                    sw->WriteLine(textBox1->Text +"  "+ textBox2->Text);//запись в строчку 
                    sw->Close();//закрытие файла
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
inter-admin
Эксперт
29715 / 6470 / 2152
Регистрация: 06.03.2009
Сообщений: 28,500
Блог
16.03.2014, 16:05
Помогаю со студенческими работами здесь

Файл: Как записать построчно массив из базы данных в файл?
всем привет! $ch = mysqli_query($dblink, &quot;SELECT * FROM `sceneries`&quot;) or die(mysql_error()); $list = array(); while ($list =...

В первый файл записать информацию о жильцах дома, во второй - информацию о квартирах
Здравствуйте! Помогите пожалуйста. найти ошибку в программе! Необходимо написать два файла, в первый информацию о жильца дома( фио,номер...

Записать информацию из нескольких TextBox в БД
собственно сабж имеется БД access, в нее необходимо добавлять записи, данные для оных берутся из TextBox`ов. пользоваться гуглом...

Записать массив в файл построчно
Доброго времени суток! Пожалуйста подскажите, мне нужно вывести все расчитанные значения в plt.- файл, что открыть в программе Tecplot и...

Построчно записать числа в файл
Напишите программу , которая в корневом каталоге диска D: создает файл numbers.txt и записывает в него 5 приведенных пользователем целых...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
2
Ответ Создать тему
Новые блоги и статьи
Первый деплой
lagorue 16.01.2026
Не спеша развернул своё 1ое приложение в kubernetes. А дальше мне интересно создать 1фронтэнд приложения и 2 бэкэнд приложения развернуть 2 деплоя в кубере получится 2 сервиса и что-бы они. . .
Расчёт переходных процессов в цепи постоянного тока
igorrr37 16.01.2026
/ * Дана цепь постоянного тока с R, L, C, k(ключ), U, E, J. Программа составляет систему уравнений по 1 и 2 законам Кирхгофа, решает её и находит токи на L и напряжения на C в установ. режимах до и. . .
Восстановить юзерскрипты Greasemonkey из бэкапа браузера
damix 15.01.2026
Если восстановить из бэкапа профиль Firefox после переустановки винды, то список юзерскриптов в Greasemonkey будет пустым. Но восстановить их можно так. Для этого понадобится консольная утилита. . .
Изучаю kubernetes
lagorue 13.01.2026
А пригодятся-ли мне знания kubernetes в России?
Сукцессия микоризы: основная теория в виде двух уравнений.
anaschu 11.01.2026
https:/ / rutube. ru/ video/ 7a537f578d808e67a3c6fd818a44a5c4/
WordPad для Windows 11
Jel 10.01.2026
WordPad для Windows 11 — это приложение, которое восстанавливает классический текстовый редактор WordPad в операционной системе Windows 11. После того как Microsoft исключила WordPad из. . .
Classic Notepad for Windows 11
Jel 10.01.2026
Old Classic Notepad for Windows 11 Приложение для Windows 11, позволяющее пользователям вернуть классическую версию текстового редактора «Блокнот» из Windows 10. Программа предоставляет более. . .
Почему дизайн решает?
Neotwalker 09.01.2026
В современном мире, где конкуренция за внимание потребителя достигла пика, дизайн становится мощным инструментом для успеха бренда. Это не просто красивый внешний вид продукта или сайта — это. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru