Visual Studio (++/#)
Microsoft: http://msdn.microsoft.com/ru-ru/library/ms229601(v=vs.110).aspx
1. Button, MessageBox
1. .
.
2. : CLR ( ) Windows Forms.
3. .
4. , .
:
1. Button
2. , Click. , .
3. :
C++: MessageBox::Show("Hello, Student!");
C#: MessageBox.Show("Hello, Student!");
:
4. F5 .
5. , , "Hello, Student!"
6. . , , .
2. BUTTON, TEXTBOX, LABEL
1.
2. "Button", "Textbox" "Label, .
3. "button1" "Text" "button1" .
4. . Form_Load, label1->Text = ""; , , () , "label1" "" ().
5. "Form1.h[]". "button1_Click". label1->Text = textBox1->Text;,.. , , : , , "textBox1" "label1".
_C++:
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
label1->Text = "";
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
label1->Text = textBox1->Text;
}
_C#:
namespace One_1_
{
public partial class Form1: Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = "";
}
private void button1_Click(object sender, EventArgs e)
{
label1.Text = textBox1.Text;
}
}
6. :
3. MessageBox MVS C++/C#
"button" "textBox", "label"
|
|
_C++:
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show(" " + textBox1->Text + "!"," ");
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
this->Text = " ";
label1->Text = ": ";
label2->Text = " ";
button1->Text = "";
}
_C#:
namespace Two_1_
{
public partial class Form1: Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Text = " ";
label1.Text = "Name: ";
label2.Text = " .";
button1.Text = "";
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(" " + textBox1.Text + "!");
}
}
}
4. MouseHover MVS C++/C#
: , , , .
1. "label". . ( ), "MouseHover" ( ).
2. label TextAlign center, .
3. Form1_Load label1_MouseHover
_C++:
#pragma endregion
private: System::Void label1_MouseHover(System::Object^ sender, System::EventArgs^ e) {
label1->TextAlign = ContentAlignment::MiddleCenter;
label1->Text = "!!!";
label1->ForeColor = Color::Red;
MessageBox::Show(" \n !", "", MessageBoxButtons::OK, MessageBoxIcon::Error);
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
Form1::Text = "Hover";
label1->TextAlign = ContentAlignment::MiddleCenter;
label1->Text = " ";
}
_C#:
namespace Three_1_
{
public partial class Form1: Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Text = "Hover";
label1.TextAlign = ContentAlignment.MiddleCenter;
label1.Text = " ";
}
private void Form1_MouseHover(object sender, EventArgs e)
{
label1.TextAlign = ContentAlignment.MiddleCenter;
label1.Text = "ERROR!!!";
label1.ForeColor = Color.Red;
MessageBox.Show(" \n !", "Fatal ERROR!",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
5. ToolTip ( ) MVS C++/C#
: , , .
1. "label", "button", "textBox" "ToolTip".
2. (-> ) "toolTip1->" "Balloon", , , . Form1_Load:
|
|
_C++:
//------------- ToolTip
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
toolTip1->SetToolTip(button1, "\r\n");
// :
toolTip1->IsBalloon = true;
// IsBalloon = false, //
}
_C#:
//------------- ToolTip
toolTip1.SetToolTip((button1, "\r\n");
toolTip1.IsBalloon = true;
}
textBox label
6. MVS C++/C#. BackGroundImage
: ( , , ). , , ("BackGroundImage") .
1. "textBox", "label", "button" :
2. "Windows Forms" , "BackGroundImage":
. (, ). ( , ).
3. "button", "BackColor" :
4. "label". "Font". 48 :
- , .
- :
_C++:
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
this->Text = " ";
label1->Text = "";
button1->Text = "";
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
label1->Text = textBox1->Text;
_C#:
namespace Four_1_
{
public partial class Form1: Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Text = " ";
label1.Text = "";
}
private void button1_Click(object sender, EventArgs e)
{
label1.Text = textBox1.Text;
}
}
}
7. PasswordChar MVS C++/C#.
: , ( *). : PasswordChar.
, , .
"Windows Forms" textBox, button pictureBox. pictureBox Image "BackgroundImage ( ). .
_C++:
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
this->Text = " ";
textBox1->PasswordChar = '*';
textBox1->TextAlign = HorizontalAlignment::Center; //
button1->Text = "";
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show(textBox1->Text, " :");
}
};
}
_C#:
namespace Five_2_
{
public partial class Form1: Form
{
public Form1()
{
InitializeComponent();
}
|
|
private void Form1_Load(object sender, EventArgs e)
{
this.Text = " ";
textBox1.PasswordChar = '*';
textBox1.TextAlign = HorizontalAlignment.Center; //
button1.Text = "";
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(textBox1.Text, " :");
}
}
}
8. PictureBox ComboBox MVS C++/C#
: , .
1. "lable", "comboBox", "PictureBox".
2. "comboBox" 3- (, ). , "label" .
3. "comboBox" , "Items" "enter" .
4.
_C++:
#pragma endregion
private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
switch (comboBox1->SelectedIndex)
{
case 0: pictureBox1->Image=Image::FromFile("d:\\8-1.jpg");
label1->Text = ""; break;
case 1: pictureBox1->Image=Image::FromFile("d:\\8-2.jpg");
label1->Text = ""; break;
case 2: pictureBox1->Image=Image::FromFile("d:\\8-3.jpg");
label1->Text = ""; break;
}
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
this->Text = " ";
label1->Text = "";
comboBox1->Text = "";
}
};
_C#
namespace Seven_1_
{
public partial class Form1: Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Text = " ";
label1.Text = "";
comboBox1.Text = "";
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBox1.SelectedIndex)
{
case 0: pictureBox1.Image=Image.FromFile("d:\\7.0.png");
label1.Text = " "; break;
case 1: pictureBox1.Image=Image.FromFile("d:\\7.1.png");
label1.Text = " "; break;
case 2: pictureBox1.Image=Image.FromFile("d:\\7.2.png")
; label1.Text = " "; break;
}
}
}
}