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

Как сделать в программе задержку между кликом по кнопке и выполнением определенного кода

19.05.2012, 22:10. Показов 1721. Ответов 6
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Здравствуйте! подскажите пожалуйста как сделать чтоб при нажатии на кнопку в progressbar отсчитывалось 20сек а потом в 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
#pragma once
 
 
namespace Restoration {
 
    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>
    /// Сводка для form2
    /// </summary>
    public ref class form2 : public System::Windows::Forms::Form
    {
    public:
        form2(void)
        {
            InitializeComponent();
            //
            //TODO: добавьте код конструктора
            //
        }
 
    protected:
        /// <summary>
        /// Освободить все используемые ресурсы.
        /// </summary>
        ~form2()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::Button^  button1;
    protected: 
    private: System::Windows::Forms::TextBox^  textBox1;
    private: System::Windows::Forms::Label^  label1;
    private: System::Windows::Forms::TextBox^  textBox2;
    private: System::Windows::Forms::Label^  label2;
    private: System::Windows::Forms::ProgressBar^  progressBar1;
 
    protected: 
 
    private:
        /// <summary>
        /// Требуется переменная конструктора.
        /// </summary>
        System::ComponentModel::Container ^components;
 
#pragma region Windows Form Designer generated code
        /// <summary>
        /// Обязательный метод для поддержки конструктора - не изменяйте
        /// содержимое данного метода при помощи редактора кода.
        /// </summary>
        void InitializeComponent(void)
        {
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->label1 = (gcnew System::Windows::Forms::Label());
            this->textBox2 = (gcnew System::Windows::Forms::TextBox());
            this->label2 = (gcnew System::Windows::Forms::Label());
            this->progressBar1 = (gcnew System::Windows::Forms::ProgressBar());
            this->SuspendLayout();
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(282, 75);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(105, 23);
            this->button1->TabIndex = 0;
            this->button1->Text = L"button1";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &form2::button1_Click);
            // 
            // textBox1
            // 
            this->textBox1->Location = System::Drawing::Point(13, 13);
            this->textBox1->Name = L"textBox1";
            this->textBox1->Size = System::Drawing::Size(197, 20);
            this->textBox1->TabIndex = 1;
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(238, 20);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(35, 13);
            this->label1->TabIndex = 2;
            this->label1->Text = L"label1";
            // 
            // textBox2
            // 
            this->textBox2->Location = System::Drawing::Point(13, 49);
            this->textBox2->Name = L"textBox2";
            this->textBox2->Size = System::Drawing::Size(197, 20);
            this->textBox2->TabIndex = 3;
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->Location = System::Drawing::Point(238, 55);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(35, 13);
            this->label2->TabIndex = 4;
            this->label2->Text = L"label2";
            // 
            // progressBar1
            // 
            this->progressBar1->Location = System::Drawing::Point(13, 75);
            this->progressBar1->Name = L"progressBar1";
            this->progressBar1->Size = System::Drawing::Size(247, 23);
            this->progressBar1->TabIndex = 5;
            // 
            // form2
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(399, 110);
            this->Controls->Add(this->progressBar1);
            this->Controls->Add(this->label2);
            this->Controls->Add(this->textBox2);
            this->Controls->Add(this->label1);
            this->Controls->Add(this->textBox1);
            this->Controls->Add(this->button1);
            this->Name = L"form2";
            this->Text = L"form2";
            this->ResumeLayout(false);
            this->PerformLayout();
 
        }
#pragma endregion
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                 this->textBox2->Text = L"OLOLO";
             }
};
}
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
19.05.2012, 22:10
Ответы с готовыми решениями:

Как сделать задержку в программе?
Dalay в программе... Как установить заданный timeout?

Как сделать задержку в программе без зависания формы
Доброго времени суток :) Никак не получается решить одну задачу. Допустим, есть форма с одной...

Как правильно сделать задержку, ожидать событие в программе?
Вот, к примеру, алгоритм: Запуск программы Подготовка данных Запуск стороннего приложения...

Как сделать задержку между командами
У меня есть код в котором три надписи подряд. Но я хочу добавить задержку между ними как это...

6
348 / 269 / 128
Регистрация: 14.11.2010
Сообщений: 482
19.05.2012, 22:18 2
Используй таймер.
0
0 / 0 / 0
Регистрация: 24.01.2012
Сообщений: 31
19.05.2012, 22:27  [ТС] 3
как это реализовать весь инет перерыл никак не могу вникнуть
0
348 / 269 / 128
Регистрация: 14.11.2010
Сообщений: 482
19.05.2012, 23:24 4
Посмотри тут:
Timer
0
0 / 0 / 0
Регистрация: 24.01.2012
Сообщений: 31
19.05.2012, 23:51  [ТС] 5
таймер я сделал а как сделать чтобы он начинал срабатывать после нажатия кнопки и progressbar тоже шевелился ! ???
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
#pragma endregion
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                
 
}
    
                
        
private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
             this->textBox2->Text = L"OLOLO";
         }
 
}
0
348 / 269 / 128
Регистрация: 14.11.2010
Сообщений: 482
20.05.2012, 00:10 6
Вот:
C++
1
2
3
4
5
6
7
8
9
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
             {
                 this->timer1->Interval = 2000;
                 this->timer1->Enabled=true;
             }
    private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) 
             {
                 this->progressBar1->Value+=5;
             }
1
0 / 0 / 0
Регистрация: 24.01.2012
Сообщений: 31
20.05.2012, 10:56  [ТС] 7
когда progressbar доходит до конца выдает ошибку: Значение '105' недопустимо для 'Value'. 'Value' должно лежать в диапазоне от 'minimum' до 'maximum'.
0
20.05.2012, 10:56
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
20.05.2012, 10:56
Помогаю со студенческими работами здесь

Как сделать Задержку между ударами
Всем привет, вот начал изучать Unity3d и пытаюсь сделать игру, столкнулся с проблемой, необходимо...

Как сделать задержку экрана после выполнения кода?
Как сделать задержку экрана после выполнения кода? В обычной idle с помощью создания файла idle,...

Как в игре сделать задержку между пропаданием хп
using System.Collections; using System.Collections.Generic; using UnityEngine; using...


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

Или воспользуйтесь поиском по форуму:
7
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru