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

Windows forms c++ ComboBox

09.07.2013, 11:05. Показов 12252. Ответов 16
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Добрый день!Возникла проблема следующего характера.
Необходимо чтобы каждому элементу из Combobox соответствовало числовое значение(для расчета формулы)
Пример, 1й элемент в списке-это углеродитая сталь ей соответствует плотность 7850. Как мне это сделать?
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// comboBox2
            // 
            this->comboBox2->DisplayMember = L"Description";
            this->comboBox2->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
            this->comboBox2->FormattingEnabled = true;
            this->comboBox2->ImeMode = System::Windows::Forms::ImeMode::NoControl;
            this->comboBox2->Items->AddRange(gcnew cli::array< System::Object^  >(27) { L"углеродистая сталь", L"04Х18Н10", L"06ХН28МДТ", 
                L"08Х13", L"08Х17Т", L"08Х20Н14С2", L"08Х18Н10", L"08Х18Н10Т", L"08Х18Н12Т", L"08Х17Н15М3Т", L"08Х22Н6Т", L"08Х18Н12Б", L"10Х17Н13М2Т", 
                L"10Х23Н18", L"12Х13", L"12Х17", L"12Х18Н10Т", L"12Х18Н12Т", L"12Х18Н9", L"15Х25Т", L"17Х18Н9", L"дюралюминий", L"титан", L"медь", 
                L"латунь", L"свинец", L"золото"});
            this->comboBox2->Location = System::Drawing::Point(153, 60);
            this->comboBox2->MaxDropDownItems = 6;
            this->comboBox2->Name = L"comboBox2";
            this->comboBox2->Size = System::Drawing::Size(128, 21);
            this->comboBox2->TabIndex = 4;
            this->comboBox2->ValueMember = L"Value";
            this->comboBox2->SelectedIndex = 0;
            this->comboBox2->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox2_SelectedIndexChanged);
Еще раз,здесь я задаю список элементов мне нужно сопоставить каждому эл-ту числовое значение.
Есть кнопка,при ее нажатии должно записываться в textlabel число,соответсвующее выбранному эл-ту в Combobox/
0
Programming
Эксперт
39485 / 9562 / 3019
Регистрация: 12.04.2006
Сообщений: 41,671
Блог
09.07.2013, 11:05
Ответы с готовыми решениями:

combobox system.windows.forms
Как добавить в combobox пункты таким способом: char text; цикл... { . . . . . . ...

Создание приложения Windows Forms на C++/CLI в Windows 8
Добрый день! Нужно создать windows приложение на Си++, стоит 8, на 2013 много заморочек с созданием windows forms. Не подскажите, можно ли...

Как сделать добавление данных просто выбрав в combobox города между связанными таблицами в Windows Forms?
Хочу сделать так чтобы при добавлении данных в с# не пришлось писать &quot;код города&quot;, а просто выбираешь в combobox &quot;конечный...

16
Каратель
Эксперт С++
6610 / 4029 / 401
Регистрация: 26.03.2010
Сообщений: 9,273
Записей в блоге: 1
09.07.2013, 11:13
вместо этого
Цитата Сообщение от sanechka6 Посмотреть сообщение
this->comboBox2->Items->AddRange(gcnew cli::array< System::Object^ *>(27) { L"углеродистая сталь", L"04Х18Н10", L"06ХН28МДТ",
* * * * * * * * L"08Х13", L"08Х17Т", L"08Х20Н14С2", L"08Х18Н10", L"08Х18Н10Т", L"08Х18Н12Т", L"08Х17Н15М3Т", L"08Х22Н6Т", L"08Х18Н12Б", L"10Х17Н13М2Т",
* * * * * * * * L"10Х23Н18", L"12Х13", L"12Х17", L"12Х18Н10Т", L"12Х18Н12Т", L"12Х18Н9", L"15Х25Т", L"17Х18Н9", L"дюралюминий", L"титан", L"медь",
* * * * * * * * L"латунь", L"свинец", L"золото"});
C++
1
2
3
4
5
Dictionary<String^, int>^ density = gcnew Dictionary<String^, int>();
//...
density->Add(L"углеродистая сталь", 7850);
//...
this->comboBox2->DataSource = density->Keys;
получаем значение так:
C++
1
int den = density[comboBox2->Text];
0
0 / 0 / 0
Регистрация: 19.12.2010
Сообщений: 31
09.07.2013, 11:28  [ТС]
попробавал,выдает ошибки:
0
Каратель
Эксперт С++
6610 / 4029 / 401
Регистрация: 26.03.2010
Сообщений: 9,273
Записей в блоге: 1
09.07.2013, 11:34
sanechka6, это
C++
1
Dictionary<String^, int>^ density = gcnew Dictionary<String^, int>();
должно быть членом класса, а у вас оно объявлено внутри метода
1
0 / 0 / 0
Регистрация: 19.12.2010
Сообщений: 31
09.07.2013, 11:44  [ТС]
Jupiter,
не понимаю куда перемесить(код ниже):
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
#pragma once
 
namespace PipeCalculator {
 
    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;
            }
        }
 
    protected: 
    private: System::Windows::Forms::Label^  label1;
    private: System::Windows::Forms::ComboBox^  comboBox1;
    private: System::Windows::Forms::Label^  label2;
    private: System::Windows::Forms::ComboBox^  comboBox2;
    private: System::Windows::Forms::Label^  label3;
    private: System::Windows::Forms::Label^  label4;
    private: System::Windows::Forms::TextBox^  textBox1;
    private: System::Windows::Forms::TextBox^  textBox2;
    private: System::Windows::Forms::Label^  label5;
    private: System::Windows::Forms::TextBox^  textBox3;
    private: System::Windows::Forms::Label^  label6;
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::Label^  label7;
    private: System::Windows::Forms::TextBox^  textBox4;
    private: System::Windows::Forms::Label^  label8;
    private: System::Windows::Forms::Label^  label9;
    private: System::Windows::Forms::TextBox^  textBox5;
 
 
    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->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
            this->label2 = (gcnew System::Windows::Forms::Label());
            this->comboBox2 = (gcnew System::Windows::Forms::ComboBox());
            this->label3 = (gcnew System::Windows::Forms::Label());
            this->label4 = (gcnew System::Windows::Forms::Label());
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->textBox2 = (gcnew System::Windows::Forms::TextBox());
            this->label5 = (gcnew System::Windows::Forms::Label());
            this->textBox3 = (gcnew System::Windows::Forms::TextBox());
            this->label6 = (gcnew System::Windows::Forms::Label());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->label7 = (gcnew System::Windows::Forms::Label());
            this->textBox4 = (gcnew System::Windows::Forms::TextBox());
            this->label8 = (gcnew System::Windows::Forms::Label());
            this->label9 = (gcnew System::Windows::Forms::Label());
            this->textBox5 = (gcnew System::Windows::Forms::TextBox());
            this->SuspendLayout();
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(31, 35);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(59, 13);
            this->label1->TabIndex = 1;
            this->label1->Text = L"Тип трубы";
            this->label1->Click += gcnew System::EventHandler(this, &Form1::label1_Click);
            // 
            // comboBox1
            // 
            this->comboBox1->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
            this->comboBox1->FormattingEnabled = true;
            this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^  >(3) {L"круглая", L"прямоугольная", L"квадратная"});
            this->comboBox1->Location = System::Drawing::Point(153, 32);
            this->comboBox1->Name = L"comboBox1";
            this->comboBox1->Size = System::Drawing::Size(109, 21);
            this->comboBox1->TabIndex = 2;
            this->comboBox1->Text = L"круглая";
            this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox1_SelectedIndexChanged);
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->Location = System::Drawing::Point(31, 63);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(57, 13);
            this->label2->TabIndex = 3;
            this->label2->Text = L"Материал";
            // 
            // comboBox2
            // 
            this->comboBox2->DisplayMember = L"Description";
            this->comboBox2->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
            this->comboBox2->FormattingEnabled = true;
            this->comboBox2->ImeMode = System::Windows::Forms::ImeMode::NoControl;
            /*this->comboBox2->Items->AddRange(gcnew cli::array< System::Object^  >(27) { L"углеродистая сталь", L"04Х18Н10", L"06ХН28МДТ", 
                L"08Х13", L"08Х17Т", L"08Х20Н14С2", L"08Х18Н10", L"08Х18Н10Т", L"08Х18Н12Т", L"08Х17Н15М3Т", L"08Х22Н6Т", L"08Х18Н12Б", L"10Х17Н13М2Т", 
                L"10Х23Н18", L"12Х13", L"12Х17", L"12Х18Н10Т", L"12Х18Н12Т", L"12Х18Н9", L"15Х25Т", L"17Х18Н9", L"дюралюминий", L"титан", L"медь", 
                L"латунь", L"свинец", L"золото"});*/
            //Dictionary<String^, int>^ density = gcnew Dictionary<String^, int>();
            Dictionary<String^, int>^ density = gcnew Dictionary<String^, int>();
            density->Add(L"углеродистая сталь", 7850);
            this->comboBox2->DataSource = density->Keys;
 
            this->comboBox2->Location = System::Drawing::Point(153, 60);
            this->comboBox2->MaxDropDownItems = 6;
            this->comboBox2->Name = L"comboBox2";
            this->comboBox2->Size = System::Drawing::Size(128, 21);
            this->comboBox2->TabIndex = 4;
            this->comboBox2->ValueMember = L"Value";
            this->comboBox2->SelectedIndex = 0;
            this->comboBox2->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox2_SelectedIndexChanged);
            // 
            // label3
            // 
            this->label3->AutoSize = true;
            this->label3->Location = System::Drawing::Point(31, 93);
            this->label3->Name = L"label3";
            this->label3->Size = System::Drawing::Size(78, 13);
            this->label3->TabIndex = 5;
            this->label3->Text = L"Диаметр (мм)";
            // 
            // label4
            // 
            this->label4->AutoSize = true;
            this->label4->Location = System::Drawing::Point(31, 183);
            this->label4->Name = L"label4";
            this->label4->Size = System::Drawing::Size(57, 13);
            this->label4->TabIndex = 6;
            this->label4->Text = L"Длина (м)";
            // 
            // textBox1
            // 
            this->textBox1->Location = System::Drawing::Point(153, 90);
            this->textBox1->Name = L"textBox1";
            this->textBox1->Size = System::Drawing::Size(100, 20);
            this->textBox1->TabIndex = 7;
            // 
            // textBox2
            // 
            this->textBox2->Location = System::Drawing::Point(153, 180);
            this->textBox2->Name = L"textBox2";
            this->textBox2->Size = System::Drawing::Size(100, 20);
            this->textBox2->TabIndex = 8;
            // 
            // label5
            // 
            this->label5->AutoSize = true;
            this->label5->Location = System::Drawing::Point(31, 155);
            this->label5->Name = L"label5";
            this->label5->Size = System::Drawing::Size(116, 13);
            this->label5->TabIndex = 9;
            this->label5->Text = L"Толщина стенки (мм)";
            // 
            // textBox3
            // 
            this->textBox3->Location = System::Drawing::Point(153, 152);
            this->textBox3->Name = L"textBox3";
            this->textBox3->Size = System::Drawing::Size(100, 20);
            this->textBox3->TabIndex = 10;
            // 
            // label6
            // 
            this->label6->AutoSize = true;
            this->label6->Font = (gcnew System::Drawing::Font(L"Freestyle Script", 14.25F, System::Drawing::FontStyle::Underline, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->label6->Location = System::Drawing::Point(25, 6);
            this->label6->Name = L"label6";
            this->label6->Size = System::Drawing::Size(256, 23);
            this->label6->TabIndex = 11;
            this->label6->Text = L"Исходные данные для трубы:";
            // 
            // button1
            // 
            this->button1->Font = (gcnew System::Drawing::Font(L"Freestyle Script", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->button1->Location = System::Drawing::Point(88, 225);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(102, 30);
            this->button1->TabIndex = 13;
            this->button1->Text = L"Вычислить";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
            // 
            // label7
            // 
            this->label7->AutoSize = true;
            this->label7->Location = System::Drawing::Point(34, 271);
            this->label7->Name = L"label7";
            this->label7->Size = System::Drawing::Size(114, 13);
            this->label7->TabIndex = 14;
            this->label7->Text = L"Масса 1го метра (кг)";
            // 
            // textBox4
            // 
            this->textBox4->Location = System::Drawing::Point(155, 268);
            this->textBox4->Name = L"textBox4";
            this->textBox4->Size = System::Drawing::Size(100, 20);
            this->textBox4->TabIndex = 15;
            // 
            // label8
            // 
            this->label8->AutoSize = true;
            this->label8->Location = System::Drawing::Point(34, 308);
            this->label8->Name = L"label8";
            this->label8->Size = System::Drawing::Size(0, 13);
            this->label8->TabIndex = 16;
            // 
            // label9
            // 
            this->label9->AutoSize = true;
            this->label9->Location = System::Drawing::Point(34, 298);
            this->label9->Name = L"label9";
            this->label9->Size = System::Drawing::Size(103, 13);
            this->label9->TabIndex = 17;
            this->label9->Text = L"Рассчет.масса (кг)";
            // 
            // textBox5
            // 
            this->textBox5->Location = System::Drawing::Point(155, 295);
            this->textBox5->Name = L"textBox5";
            this->textBox5->Size = System::Drawing::Size(100, 20);
            this->textBox5->TabIndex = 18;
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(317, 348);
            this->Controls->Add(this->textBox5);
            this->Controls->Add(this->label9);
            this->Controls->Add(this->label8);
            this->Controls->Add(this->textBox4);
            this->Controls->Add(this->label7);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->label6);
            this->Controls->Add(this->textBox3);
            this->Controls->Add(this->label5);
            this->Controls->Add(this->textBox2);
            this->Controls->Add(this->textBox1);
            this->Controls->Add(this->label4);
            this->Controls->Add(this->label3);
            this->Controls->Add(this->comboBox2);
            this->Controls->Add(this->label2);
            this->Controls->Add(this->comboBox1);
            this->Controls->Add(this->label1);
            this->Name = L"Form1";
            this->Text = L"Расчет массы трубы";
            this->ResumeLayout(false);
            this->PerformLayout();
 
        }
#pragma endregion
    private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
             }
    private: System::Void comboBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
 
             }
    private: System::Void comboBox2_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
             }
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
            int den = density[comboBox2->Text];
            textBox4->Text=System::Convert::ToString(den);
         }
 
};
}
0
Каратель
Эксперт С++
6610 / 4029 / 401
Регистрация: 26.03.2010
Сообщений: 9,273
Записей в блоге: 1
09.07.2013, 11:51
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
#pragma once
 
namespace PipeCalculator {
 
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Collections::Generic;
    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;
            }
        }
 
    protected: 
    private: System::Windows::Forms::Label^  label1;
    private: System::Windows::Forms::ComboBox^  comboBox1;
    private: System::Windows::Forms::Label^  label2;
    private: System::Windows::Forms::ComboBox^  comboBox2;
    private: System::Windows::Forms::Label^  label3;
    private: System::Windows::Forms::Label^  label4;
    private: System::Windows::Forms::TextBox^  textBox1;
    private: System::Windows::Forms::TextBox^  textBox2;
    private: System::Windows::Forms::Label^  label5;
    private: System::Windows::Forms::TextBox^  textBox3;
    private: System::Windows::Forms::Label^  label6;
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::Label^  label7;
    private: System::Windows::Forms::TextBox^  textBox4;
    private: System::Windows::Forms::Label^  label8;
    private: System::Windows::Forms::Label^  label9;
    private: System::Windows::Forms::TextBox^  textBox5;
 
 
    private:
        /// <summary>
        /// Required designer variable.
        /// </summary>
        System::ComponentModel::Container ^components;
        Dictionary<String^, int>^ mDensity;
 
#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->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
            this->label2 = (gcnew System::Windows::Forms::Label());
            this->comboBox2 = (gcnew System::Windows::Forms::ComboBox());
            this->label3 = (gcnew System::Windows::Forms::Label());
            this->label4 = (gcnew System::Windows::Forms::Label());
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->textBox2 = (gcnew System::Windows::Forms::TextBox());
            this->label5 = (gcnew System::Windows::Forms::Label());
            this->textBox3 = (gcnew System::Windows::Forms::TextBox());
            this->label6 = (gcnew System::Windows::Forms::Label());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->label7 = (gcnew System::Windows::Forms::Label());
            this->textBox4 = (gcnew System::Windows::Forms::TextBox());
            this->label8 = (gcnew System::Windows::Forms::Label());
            this->label9 = (gcnew System::Windows::Forms::Label());
            this->textBox5 = (gcnew System::Windows::Forms::TextBox());
            this->SuspendLayout();
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(31, 35);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(59, 13);
            this->label1->TabIndex = 1;
            this->label1->Text = L"Тип трубы";
            this->label1->Click += gcnew System::EventHandler(this, &Form1::label1_Click);
            // 
            // comboBox1
            // 
            this->comboBox1->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
            this->comboBox1->FormattingEnabled = true;
            this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^  >(3) {L"круглая", L"прямоугольная", L"квадратная"});
            this->comboBox1->Location = System::Drawing::Point(153, 32);
            this->comboBox1->Name = L"comboBox1";
            this->comboBox1->Size = System::Drawing::Size(109, 21);
            this->comboBox1->TabIndex = 2;
            this->comboBox1->Text = L"круглая";
            this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox1_SelectedIndexChanged);
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->Location = System::Drawing::Point(31, 63);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(57, 13);
            this->label2->TabIndex = 3;
            this->label2->Text = L"Материал";
            // 
            // comboBox2
            // 
            this->comboBox2->DisplayMember = L"Description";
            this->comboBox2->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
            this->comboBox2->FormattingEnabled = true;
            this->comboBox2->ImeMode = System::Windows::Forms::ImeMode::NoControl;
            /*this->comboBox2->Items->AddRange(gcnew cli::array< System::Object^  >(27) { L"углеродистая сталь", L"04Х18Н10", L"06ХН28МДТ", 
                L"08Х13", L"08Х17Т", L"08Х20Н14С2", L"08Х18Н10", L"08Х18Н10Т", L"08Х18Н12Т", L"08Х17Н15М3Т", L"08Х22Н6Т", L"08Х18Н12Б", L"10Х17Н13М2Т", 
                L"10Х23Н18", L"12Х13", L"12Х17", L"12Х18Н10Т", L"12Х18Н12Т", L"12Х18Н9", L"15Х25Т", L"17Х18Н9", L"дюралюминий", L"титан", L"медь", 
                L"латунь", L"свинец", L"золото"});*/
          
            
            mDensity = gcnew Dictionary<String^, int>();
            mDensity->Add(L"углеродистая сталь", 7850);
            this->comboBox2->DataSource = mDensity->Keys;
 
            this->comboBox2->Location = System::Drawing::Point(153, 60);
            this->comboBox2->MaxDropDownItems = 6;
            this->comboBox2->Name = L"comboBox2";
            this->comboBox2->Size = System::Drawing::Size(128, 21);
            this->comboBox2->TabIndex = 4;
            this->comboBox2->ValueMember = L"Value";
            this->comboBox2->SelectedIndex = 0;
            this->comboBox2->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox2_SelectedIndexChanged);
            // 
            // label3
            // 
            this->label3->AutoSize = true;
            this->label3->Location = System::Drawing::Point(31, 93);
            this->label3->Name = L"label3";
            this->label3->Size = System::Drawing::Size(78, 13);
            this->label3->TabIndex = 5;
            this->label3->Text = L"Диаметр (мм)";
            // 
            // label4
            // 
            this->label4->AutoSize = true;
            this->label4->Location = System::Drawing::Point(31, 183);
            this->label4->Name = L"label4";
            this->label4->Size = System::Drawing::Size(57, 13);
            this->label4->TabIndex = 6;
            this->label4->Text = L"Длина (м)";
            // 
            // textBox1
            // 
            this->textBox1->Location = System::Drawing::Point(153, 90);
            this->textBox1->Name = L"textBox1";
            this->textBox1->Size = System::Drawing::Size(100, 20);
            this->textBox1->TabIndex = 7;
            // 
            // textBox2
            // 
            this->textBox2->Location = System::Drawing::Point(153, 180);
            this->textBox2->Name = L"textBox2";
            this->textBox2->Size = System::Drawing::Size(100, 20);
            this->textBox2->TabIndex = 8;
            // 
            // label5
            // 
            this->label5->AutoSize = true;
            this->label5->Location = System::Drawing::Point(31, 155);
            this->label5->Name = L"label5";
            this->label5->Size = System::Drawing::Size(116, 13);
            this->label5->TabIndex = 9;
            this->label5->Text = L"Толщина стенки (мм)";
            // 
            // textBox3
            // 
            this->textBox3->Location = System::Drawing::Point(153, 152);
            this->textBox3->Name = L"textBox3";
            this->textBox3->Size = System::Drawing::Size(100, 20);
            this->textBox3->TabIndex = 10;
            // 
            // label6
            // 
            this->label6->AutoSize = true;
            this->label6->Font = (gcnew System::Drawing::Font(L"Freestyle Script", 14.25F, System::Drawing::FontStyle::Underline, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->label6->Location = System::Drawing::Point(25, 6);
            this->label6->Name = L"label6";
            this->label6->Size = System::Drawing::Size(256, 23);
            this->label6->TabIndex = 11;
            this->label6->Text = L"Исходные данные для трубы:";
            // 
            // button1
            // 
            this->button1->Font = (gcnew System::Drawing::Font(L"Freestyle Script", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->button1->Location = System::Drawing::Point(88, 225);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(102, 30);
            this->button1->TabIndex = 13;
            this->button1->Text = L"Вычислить";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
            // 
            // label7
            // 
            this->label7->AutoSize = true;
            this->label7->Location = System::Drawing::Point(34, 271);
            this->label7->Name = L"label7";
            this->label7->Size = System::Drawing::Size(114, 13);
            this->label7->TabIndex = 14;
            this->label7->Text = L"Масса 1го метра (кг)";
            // 
            // textBox4
            // 
            this->textBox4->Location = System::Drawing::Point(155, 268);
            this->textBox4->Name = L"textBox4";
            this->textBox4->Size = System::Drawing::Size(100, 20);
            this->textBox4->TabIndex = 15;
            // 
            // label8
            // 
            this->label8->AutoSize = true;
            this->label8->Location = System::Drawing::Point(34, 308);
            this->label8->Name = L"label8";
            this->label8->Size = System::Drawing::Size(0, 13);
            this->label8->TabIndex = 16;
            // 
            // label9
            // 
            this->label9->AutoSize = true;
            this->label9->Location = System::Drawing::Point(34, 298);
            this->label9->Name = L"label9";
            this->label9->Size = System::Drawing::Size(103, 13);
            this->label9->TabIndex = 17;
            this->label9->Text = L"Рассчет.масса (кг)";
            // 
            // textBox5
            // 
            this->textBox5->Location = System::Drawing::Point(155, 295);
            this->textBox5->Name = L"textBox5";
            this->textBox5->Size = System::Drawing::Size(100, 20);
            this->textBox5->TabIndex = 18;
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(317, 348);
            this->Controls->Add(this->textBox5);
            this->Controls->Add(this->label9);
            this->Controls->Add(this->label8);
            this->Controls->Add(this->textBox4);
            this->Controls->Add(this->label7);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->label6);
            this->Controls->Add(this->textBox3);
            this->Controls->Add(this->label5);
            this->Controls->Add(this->textBox2);
            this->Controls->Add(this->textBox1);
            this->Controls->Add(this->label4);
            this->Controls->Add(this->label3);
            this->Controls->Add(this->comboBox2);
            this->Controls->Add(this->label2);
            this->Controls->Add(this->comboBox1);
            this->Controls->Add(this->label1);
            this->Name = L"Form1";
            this->Text = L"Расчет массы трубы";
            this->ResumeLayout(false);
            this->PerformLayout();
 
        }
#pragma endregion
    private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
             }
    private: System::Void comboBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
 
             }
    private: System::Void comboBox2_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
             }
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
            int den = mDensity[comboBox2->Text];
            textBox4->Text=System::Convert::ToString(den);
         }
 
};
}
0
0 / 0 / 0
Регистрация: 19.12.2010
Сообщений: 31
09.07.2013, 11:55  [ТС]
Jupiter,
теперь вот такая херь:
0
Каратель
Эксперт С++
6610 / 4029 / 401
Регистрация: 26.03.2010
Сообщений: 9,273
Записей в блоге: 1
09.07.2013, 12:37
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
#pragma once
 
namespace PipeCalculator {
 
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Collections::Generic;
    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;
            }
        }
 
    protected: 
    private: System::Windows::Forms::Label^  label1;
    private: System::Windows::Forms::ComboBox^  comboBox1;
    private: System::Windows::Forms::Label^  label2;
    private: System::Windows::Forms::ComboBox^  comboBox2;
    private: System::Windows::Forms::Label^  label3;
    private: System::Windows::Forms::Label^  label4;
    private: System::Windows::Forms::TextBox^  textBox1;
    private: System::Windows::Forms::TextBox^  textBox2;
    private: System::Windows::Forms::Label^  label5;
    private: System::Windows::Forms::TextBox^  textBox3;
    private: System::Windows::Forms::Label^  label6;
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::Label^  label7;
    private: System::Windows::Forms::TextBox^  textBox4;
    private: System::Windows::Forms::Label^  label8;
    private: System::Windows::Forms::Label^  label9;
    private: System::Windows::Forms::TextBox^  textBox5;
 
 
    private:
        /// <summary>
        /// Required designer variable.
        /// </summary>
        System::ComponentModel::Container ^components;
        List<KeyValuePair<String^, int>>^ mDensity;
 
#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->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
            this->label2 = (gcnew System::Windows::Forms::Label());
            this->comboBox2 = (gcnew System::Windows::Forms::ComboBox());
            this->label3 = (gcnew System::Windows::Forms::Label());
            this->label4 = (gcnew System::Windows::Forms::Label());
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->textBox2 = (gcnew System::Windows::Forms::TextBox());
            this->label5 = (gcnew System::Windows::Forms::Label());
            this->textBox3 = (gcnew System::Windows::Forms::TextBox());
            this->label6 = (gcnew System::Windows::Forms::Label());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->label7 = (gcnew System::Windows::Forms::Label());
            this->textBox4 = (gcnew System::Windows::Forms::TextBox());
            this->label8 = (gcnew System::Windows::Forms::Label());
            this->label9 = (gcnew System::Windows::Forms::Label());
            this->textBox5 = (gcnew System::Windows::Forms::TextBox());
            this->SuspendLayout();
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(31, 35);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(59, 13);
            this->label1->TabIndex = 1;
            this->label1->Text = L"Тип трубы";
            this->label1->Click += gcnew System::EventHandler(this, &Form1::label1_Click);
            // 
            // comboBox1
            // 
            this->comboBox1->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
            this->comboBox1->FormattingEnabled = true;
            this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^  >(3) {L"круглая", L"прямоугольная", L"квадратная"});
            this->comboBox1->Location = System::Drawing::Point(153, 32);
            this->comboBox1->Name = L"comboBox1";
            this->comboBox1->Size = System::Drawing::Size(109, 21);
            this->comboBox1->TabIndex = 2;
            this->comboBox1->Text = L"круглая";
            this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox1_SelectedIndexChanged);
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->Location = System::Drawing::Point(31, 63);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(57, 13);
            this->label2->TabIndex = 3;
            this->label2->Text = L"Материал";
            // 
            // comboBox2
            // 
            this->comboBox2->DisplayMember = L"Description";
            this->comboBox2->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
            this->comboBox2->FormattingEnabled = true;
            this->comboBox2->ImeMode = System::Windows::Forms::ImeMode::NoControl;
            /*this->comboBox2->Items->AddRange(gcnew cli::array< System::Object^  >(27) { L"углеродистая сталь", L"04Х18Н10", L"06ХН28МДТ", 
                L"08Х13", L"08Х17Т", L"08Х20Н14С2", L"08Х18Н10", L"08Х18Н10Т", L"08Х18Н12Т", L"08Х17Н15М3Т", L"08Х22Н6Т", L"08Х18Н12Б", L"10Х17Н13М2Т", 
                L"10Х23Н18", L"12Х13", L"12Х17", L"12Х18Н10Т", L"12Х18Н12Т", L"12Х18Н9", L"15Х25Т", L"17Х18Н9", L"дюралюминий", L"титан", L"медь", 
                L"латунь", L"свинец", L"золото"});*/
          
            
            mDensity = gcnew List<KeyValuePair<String^, int>>();
            mDensity->Add(gcnew KeyValuePair<String^, int>(L"углеродистая сталь", 7850));
            this->comboBox2->DataSource = mDensity;
            this->comboBox2->DisplayMember = "Key";
 
            this->comboBox2->Location = System::Drawing::Point(153, 60);
            this->comboBox2->MaxDropDownItems = 6;
            this->comboBox2->Name = L"comboBox2";
            this->comboBox2->Size = System::Drawing::Size(128, 21);
            this->comboBox2->TabIndex = 4;
            this->comboBox2->ValueMember = L"Value";
            this->comboBox2->SelectedIndex = 0;
            this->comboBox2->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox2_SelectedIndexChanged);
            // 
            // label3
            // 
            this->label3->AutoSize = true;
            this->label3->Location = System::Drawing::Point(31, 93);
            this->label3->Name = L"label3";
            this->label3->Size = System::Drawing::Size(78, 13);
            this->label3->TabIndex = 5;
            this->label3->Text = L"Диаметр (мм)";
            // 
            // label4
            // 
            this->label4->AutoSize = true;
            this->label4->Location = System::Drawing::Point(31, 183);
            this->label4->Name = L"label4";
            this->label4->Size = System::Drawing::Size(57, 13);
            this->label4->TabIndex = 6;
            this->label4->Text = L"Длина (м)";
            // 
            // textBox1
            // 
            this->textBox1->Location = System::Drawing::Point(153, 90);
            this->textBox1->Name = L"textBox1";
            this->textBox1->Size = System::Drawing::Size(100, 20);
            this->textBox1->TabIndex = 7;
            // 
            // textBox2
            // 
            this->textBox2->Location = System::Drawing::Point(153, 180);
            this->textBox2->Name = L"textBox2";
            this->textBox2->Size = System::Drawing::Size(100, 20);
            this->textBox2->TabIndex = 8;
            // 
            // label5
            // 
            this->label5->AutoSize = true;
            this->label5->Location = System::Drawing::Point(31, 155);
            this->label5->Name = L"label5";
            this->label5->Size = System::Drawing::Size(116, 13);
            this->label5->TabIndex = 9;
            this->label5->Text = L"Толщина стенки (мм)";
            // 
            // textBox3
            // 
            this->textBox3->Location = System::Drawing::Point(153, 152);
            this->textBox3->Name = L"textBox3";
            this->textBox3->Size = System::Drawing::Size(100, 20);
            this->textBox3->TabIndex = 10;
            // 
            // label6
            // 
            this->label6->AutoSize = true;
            this->label6->Font = (gcnew System::Drawing::Font(L"Freestyle Script", 14.25F, System::Drawing::FontStyle::Underline, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->label6->Location = System::Drawing::Point(25, 6);
            this->label6->Name = L"label6";
            this->label6->Size = System::Drawing::Size(256, 23);
            this->label6->TabIndex = 11;
            this->label6->Text = L"Исходные данные для трубы:";
            // 
            // button1
            // 
            this->button1->Font = (gcnew System::Drawing::Font(L"Freestyle Script", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->button1->Location = System::Drawing::Point(88, 225);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(102, 30);
            this->button1->TabIndex = 13;
            this->button1->Text = L"Вычислить";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
            // 
            // label7
            // 
            this->label7->AutoSize = true;
            this->label7->Location = System::Drawing::Point(34, 271);
            this->label7->Name = L"label7";
            this->label7->Size = System::Drawing::Size(114, 13);
            this->label7->TabIndex = 14;
            this->label7->Text = L"Масса 1го метра (кг)";
            // 
            // textBox4
            // 
            this->textBox4->Location = System::Drawing::Point(155, 268);
            this->textBox4->Name = L"textBox4";
            this->textBox4->Size = System::Drawing::Size(100, 20);
            this->textBox4->TabIndex = 15;
            // 
            // label8
            // 
            this->label8->AutoSize = true;
            this->label8->Location = System::Drawing::Point(34, 308);
            this->label8->Name = L"label8";
            this->label8->Size = System::Drawing::Size(0, 13);
            this->label8->TabIndex = 16;
            // 
            // label9
            // 
            this->label9->AutoSize = true;
            this->label9->Location = System::Drawing::Point(34, 298);
            this->label9->Name = L"label9";
            this->label9->Size = System::Drawing::Size(103, 13);
            this->label9->TabIndex = 17;
            this->label9->Text = L"Рассчет.масса (кг)";
            // 
            // textBox5
            // 
            this->textBox5->Location = System::Drawing::Point(155, 295);
            this->textBox5->Name = L"textBox5";
            this->textBox5->Size = System::Drawing::Size(100, 20);
            this->textBox5->TabIndex = 18;
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(317, 348);
            this->Controls->Add(this->textBox5);
            this->Controls->Add(this->label9);
            this->Controls->Add(this->label8);
            this->Controls->Add(this->textBox4);
            this->Controls->Add(this->label7);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->label6);
            this->Controls->Add(this->textBox3);
            this->Controls->Add(this->label5);
            this->Controls->Add(this->textBox2);
            this->Controls->Add(this->textBox1);
            this->Controls->Add(this->label4);
            this->Controls->Add(this->label3);
            this->Controls->Add(this->comboBox2);
            this->Controls->Add(this->label2);
            this->Controls->Add(this->comboBox1);
            this->Controls->Add(this->label1);
            this->Name = L"Form1";
            this->Text = L"Расчет массы трубы";
            this->ResumeLayout(false);
            this->PerformLayout();
 
        }
#pragma endregion
    private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
             }
    private: System::Void comboBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
 
             }
    private: System::Void comboBox2_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
             }
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
            int den = (int)comboBox2->SelectedValue;
            textBox4->Text=System::Convert::ToString(den);
         }
 
};
}
0
0 / 0 / 0
Регистрация: 19.12.2010
Сообщений: 31
09.07.2013, 13:02  [ТС]
теперь след. выдает:
1>c:\users\alexander\documents\visual studio 2010\projects\pipecalculator\pipecalcula tor\Form1.h(137): error C2664: 'System::Collections::Generic::List<T>:: Add' : cannot convert parameter 1 from 'System::Collections::Generic::KeyValueP air<TKey,TValue> ^' to 'System::Collections::Generic::KeyValueP air<TKey,TValue>'
0
Каратель
Эксперт С++
6610 / 4029 / 401
Регистрация: 26.03.2010
Сообщений: 9,273
Записей в блоге: 1
09.07.2013, 13:09
в строке 64
C++
1
List<KeyValuePair<String^, int>^>^ mDensity;
в строке 136
C++
1
mDensity = gcnew List<KeyValuePair<String^, int>^>();
0
0 / 0 / 0
Регистрация: 19.12.2010
Сообщений: 31
09.07.2013, 13:21  [ТС]
c:\users\alexander\documents\visual studio 2010\projects\pipecalculator\pipecalcula tor\Form1.h(135): error C3225: generic type argument for 'T' cannot be 'System::Collections::Generic::KeyValueP air<TKey,TValue> ^', it must be a value type or a handle to a reference type
1> with
1> [
1> TKey=System::String ^,
1> TValue=int
1> ]
0
Каратель
Эксперт С++
6610 / 4029 / 401
Регистрация: 26.03.2010
Сообщений: 9,273
Записей в блоге: 1
09.07.2013, 13:37
проверил, теперь точно должно все работать
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
namespace PipeCalculator {
 
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Collections::Generic;
    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;
            }
        }
 
    protected: 
    private: System::Windows::Forms::Label^  label1;
    private: System::Windows::Forms::ComboBox^  comboBox1;
    private: System::Windows::Forms::Label^  label2;
    private: System::Windows::Forms::ComboBox^  comboBox2;
    private: System::Windows::Forms::Label^  label3;
    private: System::Windows::Forms::Label^  label4;
    private: System::Windows::Forms::TextBox^  textBox1;
    private: System::Windows::Forms::TextBox^  textBox2;
    private: System::Windows::Forms::Label^  label5;
    private: System::Windows::Forms::TextBox^  textBox3;
    private: System::Windows::Forms::Label^  label6;
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::Label^  label7;
    private: System::Windows::Forms::TextBox^  textBox4;
    private: System::Windows::Forms::Label^  label8;
    private: System::Windows::Forms::Label^  label9;
    private: System::Windows::Forms::TextBox^  textBox5;
 
 
    private:
        /// <summary>
        /// Required designer variable.
        /// </summary>
        System::ComponentModel::Container ^components;
        List<KeyValuePair<String^, int>>^ mDensity;
 
#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->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
            this->label2 = (gcnew System::Windows::Forms::Label());
            this->comboBox2 = (gcnew System::Windows::Forms::ComboBox());
            this->label3 = (gcnew System::Windows::Forms::Label());
            this->label4 = (gcnew System::Windows::Forms::Label());
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->textBox2 = (gcnew System::Windows::Forms::TextBox());
            this->label5 = (gcnew System::Windows::Forms::Label());
            this->textBox3 = (gcnew System::Windows::Forms::TextBox());
            this->label6 = (gcnew System::Windows::Forms::Label());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->label7 = (gcnew System::Windows::Forms::Label());
            this->textBox4 = (gcnew System::Windows::Forms::TextBox());
            this->label8 = (gcnew System::Windows::Forms::Label());
            this->label9 = (gcnew System::Windows::Forms::Label());
            this->textBox5 = (gcnew System::Windows::Forms::TextBox());
            this->SuspendLayout();
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(31, 35);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(59, 13);
            this->label1->TabIndex = 1;
            this->label1->Text = L"Тип трубы";
            this->label1->Click += gcnew System::EventHandler(this, &Form1::label1_Click);
            // 
            // comboBox1
            // 
            this->comboBox1->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
            this->comboBox1->FormattingEnabled = true;
            this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^  >(3) {L"круглая", L"прямоугольная", L"квадратная"});
            this->comboBox1->Location = System::Drawing::Point(153, 32);
            this->comboBox1->Name = L"comboBox1";
            this->comboBox1->Size = System::Drawing::Size(109, 21);
            this->comboBox1->TabIndex = 2;
            this->comboBox1->Text = L"круглая";
            this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox1_SelectedIndexChanged);
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->Location = System::Drawing::Point(31, 63);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(57, 13);
            this->label2->TabIndex = 3;
            this->label2->Text = L"Материал";
            // 
            // comboBox2
            // 
            this->comboBox2->DisplayMember = L"Description";
            this->comboBox2->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
            this->comboBox2->FormattingEnabled = true;
            this->comboBox2->ImeMode = System::Windows::Forms::ImeMode::NoControl;
            /*this->comboBox2->Items->AddRange(gcnew cli::array< System::Object^  >(27) { L"углеродистая сталь", L"04Х18Н10", L"06ХН28МДТ", 
                L"08Х13", L"08Х17Т", L"08Х20Н14С2", L"08Х18Н10", L"08Х18Н10Т", L"08Х18Н12Т", L"08Х17Н15М3Т", L"08Х22Н6Т", L"08Х18Н12Б", L"10Х17Н13М2Т", 
                L"10Х23Н18", L"12Х13", L"12Х17", L"12Х18Н10Т", L"12Х18Н12Т", L"12Х18Н9", L"15Х25Т", L"17Х18Н9", L"дюралюминий", L"титан", L"медь", 
                L"латунь", L"свинец", L"золото"});*/
          
            
            mDensity = gcnew List<KeyValuePair<String^, int>>();
            mDensity->Add(KeyValuePair<String^, int>(L"углеродистая сталь", 7850));
            this->comboBox2->DataSource = mDensity;
            this->comboBox2->DisplayMember = "Key";
 
            this->comboBox2->Location = System::Drawing::Point(153, 60);
            this->comboBox2->MaxDropDownItems = 6;
            this->comboBox2->Name = L"comboBox2";
            this->comboBox2->Size = System::Drawing::Size(128, 21);
            this->comboBox2->TabIndex = 4;
            this->comboBox2->ValueMember = L"Value";
            
            this->comboBox2->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox2_SelectedIndexChanged);
            // 
            // label3
            // 
            this->label3->AutoSize = true;
            this->label3->Location = System::Drawing::Point(31, 93);
            this->label3->Name = L"label3";
            this->label3->Size = System::Drawing::Size(78, 13);
            this->label3->TabIndex = 5;
            this->label3->Text = L"Диаметр (мм)";
            // 
            // label4
            // 
            this->label4->AutoSize = true;
            this->label4->Location = System::Drawing::Point(31, 183);
            this->label4->Name = L"label4";
            this->label4->Size = System::Drawing::Size(57, 13);
            this->label4->TabIndex = 6;
            this->label4->Text = L"Длина (м)";
            // 
            // textBox1
            // 
            this->textBox1->Location = System::Drawing::Point(153, 90);
            this->textBox1->Name = L"textBox1";
            this->textBox1->Size = System::Drawing::Size(100, 20);
            this->textBox1->TabIndex = 7;
            // 
            // textBox2
            // 
            this->textBox2->Location = System::Drawing::Point(153, 180);
            this->textBox2->Name = L"textBox2";
            this->textBox2->Size = System::Drawing::Size(100, 20);
            this->textBox2->TabIndex = 8;
            // 
            // label5
            // 
            this->label5->AutoSize = true;
            this->label5->Location = System::Drawing::Point(31, 155);
            this->label5->Name = L"label5";
            this->label5->Size = System::Drawing::Size(116, 13);
            this->label5->TabIndex = 9;
            this->label5->Text = L"Толщина стенки (мм)";
            // 
            // textBox3
            // 
            this->textBox3->Location = System::Drawing::Point(153, 152);
            this->textBox3->Name = L"textBox3";
            this->textBox3->Size = System::Drawing::Size(100, 20);
            this->textBox3->TabIndex = 10;
            // 
            // label6
            // 
            this->label6->AutoSize = true;
            this->label6->Font = (gcnew System::Drawing::Font(L"Freestyle Script", 14.25F, System::Drawing::FontStyle::Underline, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->label6->Location = System::Drawing::Point(25, 6);
            this->label6->Name = L"label6";
            this->label6->Size = System::Drawing::Size(256, 23);
            this->label6->TabIndex = 11;
            this->label6->Text = L"Исходные данные для трубы:";
            // 
            // button1
            // 
            this->button1->Font = (gcnew System::Drawing::Font(L"Freestyle Script", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->button1->Location = System::Drawing::Point(88, 225);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(102, 30);
            this->button1->TabIndex = 13;
            this->button1->Text = L"Вычислить";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
            // 
            // label7
            // 
            this->label7->AutoSize = true;
            this->label7->Location = System::Drawing::Point(34, 271);
            this->label7->Name = L"label7";
            this->label7->Size = System::Drawing::Size(114, 13);
            this->label7->TabIndex = 14;
            this->label7->Text = L"Масса 1го метра (кг)";
            // 
            // textBox4
            // 
            this->textBox4->Location = System::Drawing::Point(155, 268);
            this->textBox4->Name = L"textBox4";
            this->textBox4->Size = System::Drawing::Size(100, 20);
            this->textBox4->TabIndex = 15;
            // 
            // label8
            // 
            this->label8->AutoSize = true;
            this->label8->Location = System::Drawing::Point(34, 308);
            this->label8->Name = L"label8";
            this->label8->Size = System::Drawing::Size(0, 13);
            this->label8->TabIndex = 16;
            // 
            // label9
            // 
            this->label9->AutoSize = true;
            this->label9->Location = System::Drawing::Point(34, 298);
            this->label9->Name = L"label9";
            this->label9->Size = System::Drawing::Size(103, 13);
            this->label9->TabIndex = 17;
            this->label9->Text = L"Рассчет.масса (кг)";
            // 
            // textBox5
            // 
            this->textBox5->Location = System::Drawing::Point(155, 295);
            this->textBox5->Name = L"textBox5";
            this->textBox5->Size = System::Drawing::Size(100, 20);
            this->textBox5->TabIndex = 18;
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(317, 348);
            this->Controls->Add(this->textBox5);
            this->Controls->Add(this->label9);
            this->Controls->Add(this->label8);
            this->Controls->Add(this->textBox4);
            this->Controls->Add(this->label7);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->label6);
            this->Controls->Add(this->textBox3);
            this->Controls->Add(this->label5);
            this->Controls->Add(this->textBox2);
            this->Controls->Add(this->textBox1);
            this->Controls->Add(this->label4);
            this->Controls->Add(this->label3);
            this->Controls->Add(this->comboBox2);
            this->Controls->Add(this->label2);
            this->Controls->Add(this->comboBox1);
            this->Controls->Add(this->label1);
            this->Name = L"Form1";
            this->Text = L"Расчет массы трубы";
            this->ResumeLayout(false);
            this->PerformLayout();
 
        }
#pragma endregion
    private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
             }
    private: System::Void comboBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
 
             }
    private: System::Void comboBox2_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
             }
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
            int den = (int)comboBox2->SelectedValue;
            textBox4->Text=System::Convert::ToString(den);
         }
 
};
}
1
0 / 0 / 0
Регистрация: 19.12.2010
Сообщений: 31
09.07.2013, 15:55  [ТС]
Столкнулся с еще одной проблемой,мне необходимо чтобы в textBox записывалось число с тремя знаками после запятой,поиск не помог(:
C++
1
textBox4->Text=System::Convert::ToString(res);
Добавлено через 10 минут
все проблему решил)))) путем:System::Math::Round
0
0 / 0 / 0
Регистрация: 19.12.2010
Сообщений: 31
09.07.2013, 16:02  [ТС]
Jupiter, у меня к вам вопрос,собственно скрин:
не открывает визуальный редактор формы.на скрине-ошибка.
0
0 / 0 / 0
Регистрация: 19.12.2010
Сообщений: 31
09.07.2013, 16:05  [ТС]
0
Каратель
Эксперт С++
6610 / 4029 / 401
Регистрация: 26.03.2010
Сообщений: 9,273
Записей в блоге: 1
09.07.2013, 16:10
а что в строке 135? а. жмакайте Ignore and continue...
0
0 / 0 / 0
Регистрация: 19.12.2010
Сообщений: 31
09.07.2013, 16:17  [ТС]
Jupiter, в строке 135:
C++
1
 mDensity = gcnew List<KeyValuePair<String^, int>>();
Ход развитий такой:жму ignore and continue,выскакивает след.фигня:
Жму Да и появляется пустая форма без всех моих кнопок,боксов и тд:
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
inter-admin
Эксперт
29715 / 6470 / 2152
Регистрация: 06.03.2009
Сообщений: 28,500
Блог
09.07.2013, 16:17
Помогаю со студенческими работами здесь

Windows.Forms - Процедуры, цикл for и System.Windows.Forms.Button
Доброго времени суток. Есть WinForms программа: ... private ClickedButtonId, ClickedButtonX, ClickedButtonY:Integer; ...

Код для Windows Forms не работает в Web Forms?
В том году я делал лабораторки по Winforms. Естественно, они все у меня сохранились, и я полез в их код, вспоминать былое, так сказать,...

Оператор "+" для типов "String" и "System.Windows.Forms.ComboBox.ObjectCollection" не определен
Доброго времени суток,подскажите решение проблемы К комбобоксам привязал БД отображаются в них названия,но вноситься в базу должны ключи...

Forms, Buttons, TextBox, ComboBox и др
Помогите, как в турбо паскале создавать формы , ставить на них кнопки, создавать к ним события, и др. Может быть подкинете примерчик этой...

Проблема с OLEObject, Forms.ComboBox, DropDown
Здравствуйте! Вопрос такой: на листе находится Forms.ComboBox. В начале Visible = False. при правом щелчке, если этот щелчок на...


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

Или воспользуйтесь поиском по форуму:
17
Ответ Создать тему
Новые блоги и статьи
SDL3 для Desktop (MinGW): Создаём пустое окно с нуля для 2D-графики на SDL3, Си и C++
8Observer8 10.03.2026
Содержание блога Финальные проекты на Си и на C++: hello-sdl3-c. zip hello-sdl3-cpp. zip Результат:
Установка CMake и MinGW 13.1 для сборки С и C++ приложений из консоли и из Qt Creator в EXE
8Observer8 10.03.2026
Содержание блога MinGW - это коллекция инструментов для сборки приложений в EXE. CMake - это система сборки приложений. Здесь описаны базовые шаги для старта программирования с помощью CMake и. . .
Как дизайн сайта влияет на конверсию: 7 решений, которые реально повышают заявки
Neotwalker 08.03.2026
Многие до сих пор воспринимают дизайн сайта как “красивую оболочку”. На практике всё иначе: дизайн напрямую влияет на то, оставит человек заявку или уйдёт через несколько секунд. Даже если у вас. . .
Модульная разработка через nuget packages
DevAlt 07.03.2026
Сложившийся в . Net-среде способ разработки чаще всего предполагает монорепозиторий в котором находятся все исходники. При создании нового решения, мы просто добавляем нужные проекты и имеем. . .
Модульный подход на примере F#
DevAlt 06.03.2026
В блоге дяди Боба наткнулся на такое определение: В этой книге («Подход, основанный на вариантах использования») Ивар утверждает, что архитектура программного обеспечения — это структуры,. . .
Управление камерой с помощью скрипта OrbitControls.js на Three.js: Вращение, зум и панорамирование
8Observer8 05.03.2026
Содержание блога Финальная демка в браузере работает на Desktop и мобильных браузерах. Итоговый код: orbit-controls-threejs-js. zip. Сканируйте QR-код на мобильном. Вращайте камеру одним пальцем,. . .
SDL3 для Web (WebAssembly): Синхронизация спрайтов SDL3 и тел Box2D
8Observer8 04.03.2026
Содержание блога Финальная демка в браузере. Итоговый код: finish-sync-physics-sprites-sdl3-c. zip На первой гифке отладочные линии отключены, а на второй включены:. . .
SDL3 для Web (WebAssembly): Идентификация объектов на Box2D v3 - использование userData и событий коллизий
8Observer8 02.03.2026
Содержание блога Финальная демка в браузере. Итоговый код: finish-collision-events-sdl3-c. zip Сканируйте QR-код на мобильном и вы увидите, что появится джойстик для управления главным героем. . . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru