OPI_LR2011_ch2m1
.pdf21
static void Main()
{
Application.Run (new Form1 () ) ;
}
private void buttondelete_Click (object sender, System.EventArgs e)
{
}
private void buttonadd_Click (object sender, System.EventArgs
e)
{
}
}
}
^ «h» «@». • , «h»
, , . h
+ ^ buttonadd_Click , (:
private void buttonadd_ciick(object sender, System.EventArgs e)
{
//ZPik\< QT R < SS ZTQSRj //Z STZ \< hR YZP Rl < ^ R ^ if (peoplelist.Text.Length != 0)
{
//j < YZP Rl, Z R< l_ S R ^hP R TS memberlist.Items.Add(peoplelist.Text) ;
}
else
{
//j < YZP Rl
// SR P\< T q Z<PiTl ST < MessageBox.Show("rY ZT [ < S R ^ SS PY SS-
T [ SRl.");
}
}
/ + . 8 memberlist.Items.Add ] memberlist. '
+ ] peoplelist.Text,
] . = Y -
. h + buttondelete_Click.
private void buttondelete_Click (object sender, System.EventArgs e) {
//R R Q Ph Rs < TS Z t Tl while(memberlist.CheckedIndices.Count > 0) {
//SR P \< TQ QP_P [_ R ^ ^hP R TS <^ < ^
//ZR i[ <^ R Q Ph Rs < TS PS <P Rh S k\ [
22
//P R< hR <, j ZPQ ^ [ SRl < TQ CheckedIndices //Y^ <T R R T Z`_ Q Ph_ S R ^ Y'\ P memberlist.Items.RemoveAt(memberlist.CheckedIndices[0] ) ;
//ZR SR P T QT R ^ P [_ Q Ph_ < P
//CheckedIndices.Count P ZTS R< ^ k
//T iR PS <P Rh QPS Z`R [
}
}
8 CheckedListBox.Items.RemoveAt ] -
. ' , \ -
, Y ^ ^. { '
Y .
9 CheckedListBox CheckedIndices,
] ^ . {
( ^], \ -
. 6 ] ,
CheckedIndices ^ (: -
. { ( ^ ,
CheckedIndices Y .
1.3 "3 2 3 7
1.3.1/
^ , ^ , ( -
.
1.3.2@ Visual Studio.
1.3.3@ :
(] ):
1.2 TextBox
Button. , \
Button TextBox - ^ Y.
2.2 TextBox. -
\ ^
Y .
1 ( ( ]
):
23
1.2 . -
, \ ^ -
, ( -
. ' (:
.
2.2 . -
, \ ^ -
, -
. ' (: -
.
3.2 . -
, \ 1 ^
Y 2 3, ( . '-
( ^ 2
3 ( CheckBox).
4.2 . -
, \ , \ ] ,
1 ^ Y
2 3. ' ( ^-
2 3 (
RadioButton).
5.2 . ?-
( (*)
, .
6.2 . ?-
(/)
, .
7.2 . ?-
(+) -
, .
8.2 . ?-
^ (-)
, .
9.2 . ?-
- + ^ (* / + -) -
, \ TextBox. @-
24
+ (/ * - +)
.
10.2 . ?-
- + ^ (* / + -) -
, \ TextBox. @-
+ (/ * - +) , \ -
^
. ' + ^ ’ -
.
1.3.4/+ .
1.3.5@ .
1.4 !4 #"4
1.4.1= .
1.4.2.
1.4.39 .
1.4.49 , \ - ( ^ .
1.4.5@, \
(5 Y. ), ( ( ^ -
.
1.5 6^ 4 # 7 2
1.5.1• + ] Visual Studio?
1.5.2• ^ C#?
1.5.3€ C#?
1.5.4• Button?
1.5.5• CheckBox?
1.5.6• RadioButton?
1.5.7< CheckBox RadioButton.
1.5.8• GroupBox?
1.5.9• TextBox?
1.5.10• RichTextBox?
25
1.5.11' TextBox RichTextBox.
1.5.122 ListBox, CheckedListBox, ComboBox: -
.
1.5.13• ListBox?
1.5.14• CheckedListBox?
1.5.15• ComboBox?
26
2 B 9 9 9 B 2 9@` 9a B A9 `9
2.1 5 7
@ ]
.
2.2 " 4 5 5 7K 4 "43 ! 4
2.2.1 4 8 – Label
– | Label
Y - + +. <, ( ] ( . . 2.1).
8 TestListsForm Y
Label «@ \
». { \ ] .
? 2.1 – h Label +
TestLists
27
2.2.2 4 8 – LinkLabel
– Linklabel ] ^ ,
1. ? ^ Visual Studio .NET -
(
Label).
2.2.3 B41 8 – TrackBar
– =
TrackBar ] Windows. TrackBar (
(: -
(, ^ . ? -
TrackBar .
2.2.4 378 1 5 – ProgressBar
– < Y ProgressBar ^
( Y ] Y .
2.2.5951 62 K7 6 "7Z # K5 ^ – dumericUpDown
– h ]
. h -
] ( : Y ^
( - , - -
.
h Y Y ] + \-
, . < Y ,
^ . h : NumericUpDown ^ -
. =, , Y
( .
2 Windows Forms ^ TestIndicator.
' + Forms1.cs TestIndicatorForm.cs. =
+ ( . 2.2):
TrackBar
28
ProgressBar
NumericUpDown.
. @
TrackBar1:
Maximum —100
TickStyle — Both
' TrackBar . S -
+, ( ' , . { -
TickStyle. h ] - Y .
Both ( ). 9 , ( Y
, . @ Minimum Maximum ^ ,
( ^ TrackBar. -
100, 0 (Y ). =, (,
Value 0, (
( Value
100.
? 2.2 – ' + TestIndicator
@ '] numericUpDown1 Y -
. | NumericUpDown ( ] Minimum Maximum. 1 , Minimum ^]
0, Maximum ^] 100. { ] ,
'] trackBar1. h ( ( -
NumericUpDown – DecimalPlaces. @ ]
. ^ Y -
29
– 0, ( Y , (
, ^ ] -
.
Text + «9 ». o . @ ] ,
Y ] + ^ 2#.
using System;
using System.Drawing; using System.Collections;
using System.ComponentModel; using System.Windows.Forms; namespaœ TestIndicator
{
//<summary>
//Required description for Form1
//</summary>
public class Form1: System.Windows.Forms.Form
{
private System.Windows.Forms.TrackBar trackbar1; private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.NumericUpDown numericUpDown1; //<summary>
// Required designer variable. //</summary>
private System.ComponentModel.Container components = null;
public Form1 ()
{
//Required for Windows Form Designer support InitializeComponent();
//TODO: Add any constructor code after Initializecomponent call
}
//<summary>
//Clean up any resources being used.
//</summary>
protected override void Dispose ( bool disposing )
{
if ( disposing ) {
if (components!= null) { components.Disposed();
}
}
base.Dispose ( disposing );
}
# region Windows Form designer generated code
#endregion
//<summary>
// The main entry point for the application.
30
// </summary> [Statread]
static void main ()
{
Application.Run (new Form1 () ) ;
}
}
}
| Numericupdown1 trackbar1 ] ^,
progressbar1 – . ^
. 9 Trackbar ] ^ Scroll, -
\ ( . 2 +- ^ ^ Scroll, Y (
Y .
+ trackbar1_Scroll. , (-:
private void trackBar1_Scroll(object Sender, System.EventArgs e)
{
int Value = trackBar1.Value; numericUpDown1.Value = Value; progressBar1.Value = Value;
}
= ^ ( -
numericupdown1. / \
, \
: (NumericUpDown), ( Y . h-
^ ValueChanged numericUpDown1. h ( Y ValueChanged . +
numericUpDown1_ValueChanged.
+ trackBar1_Scroll.
private void numericUpDown1_ValueChanged (object sender, System.EventArgs e)
{
int Value = (int)numericUpDown1.Value; trackBar1.Value = Value; progressBar1.Value = Value;
}
@ ^ . 2 - ( . '
. 2
^ . |+