forked from dotnet/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource.cpp
50 lines (43 loc) · 1.11 KB
/
source.cpp
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
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Windows::Forms;
public ref class Form1: public Form
{
protected:
ListBox^ listBox1;
// <Snippet1>
public:
static void main()
{
// Starts the application.
Application::Run( gcnew Form1 );
}
private:
void button1_Click( Object^ sender, System::EventArgs^ e )
{
// Populates a list box with three numbers.
int i = 3;
for ( int j = 1; j <= i; j++ )
{
listBox1->Items->Add( j );
}
/* Determines whether the user wants to exit the application.
* If not, adds another number to the list box. */
while ( MessageBox::Show( "Exit application?", "",
MessageBoxButtons::YesNo ) == ::DialogResult::No )
{
// Increments the counter ands add the number to the list box.
i++;
listBox1->Items->Add( i );
}
// The user wants to exit the application. Close everything down.
Application::Exit();
}
// </Snippet1>
};
int main()
{
Form1::main();
}