Delphi
Visual C# . 12. .
.
.
,
. ,
button1 ("
"):
private
void button1_Click(object
sender, EventArgs e)
{
if
(form2.Visible) form2.Close(); else
form2.Show();
} |
form2, .
2, ,
*:

AutoSize
false, Dock = Fill, TextAlign =
MiddleCenter. 2, ,
FormClosing
VisibleCanged:
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using System.Windows.Forms;
namespace
WindowsFormsApplication1
{
public partial
class Form2
: Form
{
private int
count;
public Form2()
{
InitializeComponent();
}
private
void Form2_FormClosing(object
sender, FormClosingEventArgs e)
{
if (e.CloseReason ==
CloseReason.UserClosing)
{
e.Cancel =
true;
if (MessageBox.Show("
?", "",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question) ==
DialogResult.Yes)
{
Hide();
Owner.Activate();
}
}
}
private void
Form2_VisibleChanged(object sender,
EventArgs e)
{
Owner.Controls["button1"].Text=Visible
?
" "
: " ";
if
(Visible) label1.Text = "
"
+ (++count) + "
";
}
}
} |
2 :

"",
, ( "
") . ,
, 2:

:

Owner.
3:

"" "" ,
3 AcceptButton
"", CancelButton "".
"" :
internal void
button2_Click(object sender,
EventArgs e)
{
Owner.Text = textBox1.Text;
Owner.OwnedForms[0].Text = textBox2.Text;
} |
,
internal - ,
.
VisibleChange 3:
private void
Form3_VisibleChanged(object sender,
EventArgs e)
{
if (Visible)
ActiveControl = textBox1;
} |
, ,
, textBox1.
button2_Click :
private void
button2_Click(object sender,
EventArgs e)
{
if (form3.ShowDialog() ==
DialogResult.OK)
{
form3.button2_Click(this,
EventArgs.Empty);
}
} |
"" ""
2, ""
3 . 3
"", 2:

, *,
"Microsoft Visual Studio 2010 Professional",
Microsoft..
()
|