
лабораторные С#
.pdf5.) ParentForm.cs " %.
6.) "! IsMdiContainer # $ True. " " , ) " %# # # * ) " MDI.
'
7.# % " File:
a.Toolbox, # * ) "% / MenuStrip # # Name $ MdiMenu.
b.!# " & $ ) "! # " % " &File.
c.Name % " File # $
FileMenuItem.
d." File.
e. |
!# , ", 0 |
# , " " File, # |
||||||
|
&New. |
|
|
|
|
|
|
|
f. |
|
Name |
% " |
New |
# |
$ |
||
|
NewMenuItem. |
|
|
|
|
|
|
|
g. |
!# , ", |
0 |
|
# |
, " " |
New, |
||
|
# &Exit. |
|
|
|
|
|
|
|
h. |
Name |
% " |
Exit |
# |
$ |
|||
|
ExitMenuItem. |
|
|
|
|
|
|
|
i. |
#! "!0 |
|
% % " Exit |
|||||
|
# |
# $ ! |
Click. |
|
|
|
||
j. |
$ ! |
Click # |
% " Exit # * |
|||||
|
#% ( #: |
|
|
|
|
|
|
this.Close();
8.# % " Window:
a.$* " %.
b.!# % " File #$" &Window.
c.Name % " Window # $
WindowMenuItem.
d." Window.
e. |
!# , ", |
0 |
# , " " Window, |
|
# # Text $ &Cascade. |
||
f. |
Name |
% " Cascade # $ |
|
|
WindowCascadeMenuItem. |
|
|
g. |
!# , ", |
0 |
# , " " Cascade, |
|
# # Text $ &Tile. |
h.Name % " Tile # $
WindowTileMenuItem.
i.#! "!0 % % "
Cascade # # $ ! Click:
this.LayoutMdi (System.Windows.Forms.MdiLayout.Cascade);
11
j. * " % # #!"!0 % % " Tile.
k. $ ! Click # % " Tile # * #% ( #:
this.LayoutMdi(System.Windows.Forms.MdiLayout.TileHorizontal);
9.% ! !& " Window:
a.% ! " Mdimenu.MdiWindowListItem " %, # # , – WindowMenuItem.
10. # #$ ) "%:
a. ! % " Project | Add Windows Form.
b.2 # " ) "! ChildForm.cs.
c.Text ) "! # $ Child Form.
d.Toolbox # #! "!0 / RichTextBox # # Name $
ChildTextBox.
e.Dock / RichTextBox # $ Fill.
f.# %( % ( ( *) # Text
/ RichTextBox * % !".
g.Toolbox # #! "!0 /
MenuStrip.
h.Name / MenuStrip # $
ChildWindowMenu.
i.!# " & $ ) "!
F&ormat.
j.Name % " Format # $
FormatMenuItem, # MergeAction %
$ Insert, % MergeIndex – 1. , " %$
" Format %# * |
File 1 # |
#$& ". |
|
k. !# , ", 0 |
# , " " Format, |
&Toggle Foreground.
l.Name % " Toggle Foreground #$ ToggleMenuItem.
m.#! "!0 % % " Toggle Foreground # * #% ( # $
! Click:
if (ToggleMenuItem.Checked)
{
ToggleMenuItem.Checked = false; ChildTextBox.ForeColor = System.Drawing.Color.Black;
}
else
{
ToggleMenuItem.Checked = true;
12
ChildTextBox.ForeColor = System.Drawing.Color.Blue;
}
(
11.#$ ) "% # * ) ":
a.ParentForm.cs " %.
b.#! "!0 New "
|
File # |
# |
$ ! |
Click. |
|
|
|
|||||||||
c. |
* #% ( # # |
$ ! |
Click # |
|||||||||||||
|
% " New: |
|
|
|
|
|
|
|
|
|
|
|||||
ChildForm newChild = new ChildForm(); |
|
|
|
|
|
|||||||||||
newChild.MdiParent = this; |
|
|
|
|
|
|
|
|||||||||
newChild.Show(); |
|
|
|
|
|
|
|
|
|
|
|
|||||
( |
|
|
|
|
|
|
|
|
|
|
|
|||||
12. * % |
: |
|
|
|
|
|
|
|
||||||||
a. |
% |
. |
|
|
|
|
|
|
||||||||
b. |
# |
|
|
# * |
) ", |
! % " |
||||||||||
|
File | New. |
|
|
|
|
|
|
|
|
|
|
|
|
|||
c. |
|
# * " |
|
|
|
#$ |
) ". |
|||||||||
|
|
" |
|
, #$ " |
|
|||||||||||
|
# * " |
% ! " % #$ |
|
|||||||||||||
|
" MergeIndex, % !" . |
|
|
|||||||||||||
d. |
-%#* |
|
|
#$" |
|
|
||||||||||
|
* % * |
% " " Format # |
" ' |
|||||||||||||
|
0 ) . |
|
|
|
|
|
|
|
|
|
|
|
|
|||
e. |
( * #$& . |
|
|
|
|
|||||||||||
f. |
! |
% " Window | Tile. " |
||||||||||||||
|
, |
$ |
|
#$ |
|
! |
|
% #$" |
||||||||
|
#. |
|
|
|
|
|
|
|
|
|
|
|
|
|
||
g. |
2 #$ . |
|
|
|
|
|
|
|
||||||||
h. |
|
" , $ , # |
# |
|||||||||||||
|
#$ , " # * ) "! " , %# |
|||||||||||||||
|
$ |
% Format. |
|
|
|
|
|
|
|
|
||||||
i. |
|
! |
|
! |
% " File | Exit. |
|
13. ", $ % #$& # !.# * & # %", " Microsoft Word, ! %"N, # N — " # %". % , % " *:
a. # # * ) "! ParentForm 1 " % openDocuments:
private int openDocuments = 0;
b.% Text #$ ) "! # * $ $ $ ! "!& # %" ( # $ ! Click
# % " New):
newChild.Text = newChild.Text+" "+ ++openDocuments;
13
14. |
2 % |
. * !& # %" |
||
# |
# ! ". |
|
||
|
|
|||
|
% % |
# ) " Windows |
||
! #% ( # . |
|
|||
|
1. # * * % ) "%, " |
|||
! |
%# |
" * * $ . |
) " # |
|
# * )% ' * *, # (% " * |
* |
|||
! * " |
! . |
|
" # ' : ) "! # , * % #% ( #:
//Добавление эллипса, вписанного в прямоугольную форму
//заданной ширины и высоты
myPath.AddEllipse(0, 0, this.Width, this.Height);
2. # # %" ) " " % % ) "% %. # , $! % ) " $* # " " * !& " # )% ' * *, # (% " * * ! * % ) "%, (% # " ' ( ' ") ! ) "! # * GREENPEACE.
2. )
%$ * , " % %$ ! !.
1. Click MouseMove
/ " ! % – , " !, 1 # ( )$
) |
|
# * |
|
)% ' * *. |
||||||
/ " ! % |
# |
" |
* % "! |
|||||||
#, |
#$! # |
! |
# !& #$. |
|||||||
, " ! % |
|
# !" Control, |
||||||||
$ , |
* % |
$! , # ( |
", |
|||||||
# % ! ! , " % . |
|
|||||||||
! |
% , # , |
! # # |
|
|||||||
, |
( |
! |
"!0, |
! |
& # % |
, " % .
* )
1.# Windows . WinQuestion.
2.) " # Button # * Label, " & -"% % ".
3.#% ( , " % ) "!:
14

+ |
|
|
Form1 |
FormBorderStyle |
Fixed3D |
|
Size |
350; 200 |
|
Text |
%( ! |
label1 |
Text |
! # * ! ? |
Button1 |
Name |
btnyes |
|
Text |
|
Button2 |
Name |
btnno |
|
Text |
|
4. 4 # #! " ". $ , # * #% ( #:
MessageBox.Show("Мы и не сомневались, что Вы так думаете!");
5.!# % " ". Properties $* ! # #! ( MouseMove.
6.$ , ! # * # # !
# "!0 # " % #, %#%# " ( * :
btnno.Top -= e.Y; btnno.Left += e.X;
if (btnno.Top < -10 || btnno.Top > 100) btnno.Top = 60;
if (btnno.Left < -80 || btnno.Left > 250) btnno.Left = 120;
7. 2 % " #% .
2.
!" , " " % " ListBox, ComboBox CheckedListBox. " ! $ 0 " # ! )% ' * ! ", #
) " % |
# # !& $ ' |
||
Items, |
" % , " !, # ( # , & |
||
, " % . |
|
|
|
ListBox — "! |
, " % . % |
||
!" " # |
|
, " |
|
* * " ), "% " ( * . |
|||
CheckedListBox – |
"$"! |
. 6 # * |
. 3 # * # — $ $# " #!" , " " . * * " " * " * # * , " , ! ).
ComboBox – ! # ( . ) " # * # $ , . & # " * * " ! * ! * # % % ( $.
15

(, '*
1. # ! Windows Forms, % " TestList.
2.* ) "% #% ( , " ! % :
a.GroupBox,
b.CheckedListBox ( " GroupBox)
c.ComboBox
d., " Button.
3.#% ( ) "! , " % :
|
+ |
|
|
|
|
|
Form1 |
FormBorderStyle |
Fixed3D |
|
|
|
|
Text |
|
" |
|
|
|
Size |
|
410;310 |
|
|
groupBox1 |
Text |
|
%$ |
|
|
CheckedListBox |
Name |
|
memberList |
|
|
ComboBox |
Name |
|
peopleList |
|
|
|
Text |
|
|
|
|
Button1 |
Name |
|
buttonAdd |
|
|
|
Text |
|
* |
|
|
Button2 |
Name |
|
buttonDelete |
|
|
|
Text |
|
# * |
|
|
Button3 |
Name |
|
buttonSort |
|
|
|
Text |
|
* |
|
4. ' % , " |
% ComboBox " |
||||
# "!& %$ . , peopleList ! |
Items. |
String Collection Editor, % |
||||
" |
$" |
Items. |
* |
|
-. . . * & |
%$ . " OK. |
|
|
|
||
5. |
* $ # |
# ,, # |
|||
( % "!0 # . |
|
||||
6. |
|
$ |
! |
|
# * |
#% ( #: |
|
|
|
|
if (peopleList.Text.Length != 0)
{
memberList.Items.Add(peopleList.Text);
}
else MessageBox.Show("Выберите элемент из списка или введите новый");
7. ' %# , " # #$ ! ,:
while (memberList.CheckedIndices.Count > 0) memberList.Items.RemoveAt(memberList.CheckedIndices[0]);
8. ' , " # #$ ! :
memberList.Sorted = true;
16
9. " % % . 2 %$ , ! & , " ComboBox. 2 0 ! # ! , , " # * & . % %$ .
3. ToolStrip
ToolStrip – , |
, " % , ! ' * |
% ( # |
* * & %", ! |
! # , |
%" Microsoft Office Microsoft |
||
Internet |
Explorer. * % , " % |
ToolStrip, ! " |
|
! |
! * |
"! |
%" |
) * #.
# !
1.MdiApplication.
2.) "% ParentForm " %.
3.* ) "% / ToolStrip.
4.) " ! # ( / ToolStrip ! button – # , " toolStripButton1. %" # # % ", $( " )% ', % , , " #.
5.! # ( / ToolStrip ! Separator – # , ", ! # # , " ! %" # % &.
6.# # * ( # – , " ! toolStripButton2 toolStripButton3.
7.! # ! %$* , # ! # " # ".
( )-
8.! % %. # *, $ Properties % DisplayStyle # $ Image.
9.Properties ! , " % ,
( % Image ! % ( % *"% # " Select Resource. 3 % * ! ) !
#& # ( & , ! &, |
" %$ % |
||||||||
% |
. !& " |
||||||||
)$& ) & |
|
\Microsoft Visual |
Studio |
||||||
9.0\Common7\VS2008ImageLibrary\ . |
|
|
|
|
|||||
|
10. |
#!#%( # |
% # |
* !& . |
|
||||
|
- ( |
||||||||
|
11. 3 % # !& %, " # |
||||||||
# |
" )$& " * & # *. |
||||||||
|
! " # %( % Image Editor. |
||||||||
|
|
# * |
|
* " 0 & |
|||||
%". |
|
|
|
|
|
|
|
||
|
12. |
|
# |
) |
|
" ! |
" |
||
File | New | File... |
0 " New |
File ! |
) |
||||||
|
|
|
|
|
|
|
17 |
|
|
“- $ $ %”, " Open. |
% |
|||
# * |
* % . " " |
! |
||
% " Image. |
" |
|||
! " |
% Image | Show Colors Window (" |
|||
|
). |
|
|
|
13. |
# |
"% % " # |
New, |
", # & ) " "
Icon_New.bmp 0 ". |
|
|
|
|
|
|
|||||
14. |
|
# |
# |
# |
# |
# % & |
, |
||||
", # !& ! " % C T. & |
|||||||||||
|
|
|
|
0 " |
|
) ! |
|
" " |
|||
Icon_Windows_Cascade.bmp Icon_Windows_Title.bmp . |
|||||||||||
15. |
! |
# |
# |
% |
!& |
, " |
|||||
". |
|
|
|
|
|
|
|
|
|
|
|
16. |
& |
|
% |
. |
* |
# |
|
||||
* . |
|
|
|
|
|
|
|
|
#
17.* $ ! Click 1 toolStrip1, ( % # % " "!0 " ! Click # !. ""% # )% ' toolStrip1_ItemClicked$ ! , & # ( %".
18.Properties # toolStripButton1 Tag 0
NewDoc. $ % # toolStripButton2 toolStripButton3 #Tag $ Cascade Title .
19.# ! ( #
ToolTipText: Create new document, Windows cascade Windows title.
20.$ ! Click 1 toolStrip1_ItemClicked # * #, ! %# ! * $! # " " " :
switch(e.ClickedItem.Tag.ToString())
{
case "NewDoc":
ChildForm newChild = new ChildForm(); newChild.MdiParent = this; newChild.Show();
newChild.Text = newChild.Text+" "+ ++openDocuments;
break; case "Cascade":
this.LayoutMdi (System.Windows.Forms.MdiLayout.Cascade); break;
case "Title": this.LayoutMdi
(System.Windows.Forms.MdiLayout.TileHorizontal);
break;
}
18

21. |
" % |
|
% |
. |
* |
||
* |
. |
|
|
|
|
|
|
4. StatusStrip |
|
||||||
/ " % |
StatusStrip " |
"" & # |
|||||
! # |
) " ' |
|
% |
|
— |
*0% |
%, |
% % |
. , " % ! # |
MdiApplication % , !' ! # %( #.
1.MdiApplication.
2.$* " ) "! ParentForm # $ (450;350).
3.* ) "% ParentForm , " % StatusStrip.
4. |
# # " |
Text. |
|
|
|
|
|
|||||
5. |
4 % ! # ( |
|
|
! |
||||||||
StatusLabel. , " toolStripStatusLabel1 – |
|
* # |
||||||||||
. |
|
|
|
|
|
|
|
|
|
|
||
6. |
# ( |
# % |
* |
$!" " |
– |
|||||||
toolStripStatusLabel2 % " #% ( : |
|
|
||||||||||
|
|
|
+ |
|
|
|
|
|
|
|
||
|
|
|
|
* |
Text |
|
Status |
|
|
|
|
|
|
|
|
|
|
Name |
|
spWin |
|
|
|
|
|
|
|
|
|
* |
Text |
|
Data |
|
|
|
|
|
|
|
|
|
|
Name |
|
spData |
|
|
|
|
|
7. |
|
|
) " ' |
|
|
|
* |
|
||||
% ( $ " # " |
|
|||||||||||
%" #% (% % #: |
|
|
|
|
|
|
|
|||||
|
a. |
# ': |
|
|
|
|
|
|
|
|||
|
|
spWin.Text="Windows is cascade"; |
|
|
|
|
|
|
b. * ':
spWin.Text="Windows is horizontal";
8. # ! % ) "! ParentForm # * #:
public ParentForm()
{
InitializeComponent();
// Свойству Text панели spData устанавливается текущая дата spData.Text =
Convert.ToString(System.DateTime.Today.ToLongDateString());
}
9. " % % . ** .
5.
— , ' ! , " ! % , ! % ( " " ( # # % & , " % . !" , " " %Panel GroupBox. # ) " $
19
)$ |
# # !, ! |
" % |
% * # % , " ! |
% |
# ! # % ! |
* * ). |
|
", |
, " % |
GroupBox # |
|
!& , " % |
RadioButton. ! , " ! |
||
% |
" % " # * (%( ) " ' |
||
* * " ) |
% * |
, " " % , ! # &.
! , % , ! %$* # * ) "! Windows* " $!& !& , " % .
( ' )
-
1.Visual Studio # ! Windows Forms.
WinContainer.
2.( Toolbox ) "% , " % TabControl.Properties # % Dock $ Fill.
3.Properties ! TabPages, $! ! *
TabPage Collection Editor. * # , $! & |
*. |
|||
2 # |
" Text , & |
, " |
% TabPage |
|
$ |
GroupBox, Panel, |
FlowLayoutPanel, |
TableLayoutPanel |
|
SplitContainer. 4 .
& ) GroupBox
4. ) " ! # % GroupBox. ( , " % GroupBox Toolbox , " % TabPage.
5.( GroupBox # , " % RadioButton.
6.* # % GroupBox , " % GroupBox% (, " % Button). Text # % !", % Name % $ but.
7.#! # * # $ ! % # " ! $
(RadioButton):
if (radioButton1.Checked == true) this.but.Text = "First";
else if (radioButton2.Checked == true) this.but.Text = "Second";
& ) Panel
8.! ) " # % Panel. ( , " % Panel Toolbox , " % TabPage. , " Panel # % Dock $ Fill.
9.( $! , " % Button Toolbox , " % Panel.
10.% AutoScroll % $ True, , " %$ , " % Panel %# * ! %, , " ! & # # " # "!& '.
20