Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

OPI_LR2011_ch2m1

.pdf
Скачиваний:
7
Добавлен:
07.02.2016
Размер:
1.35 Mб
Скачать

31

. 2 ] (

( . 2.3).

? 2.3 – @ «9 »

2.2.6 7 8 – ListView

| ListView

( . 9 ListView ]

ListBox Y (:

( , ( -

, . = -

ListView ] «'»,

Microsoft Windows ( . 2.4).

? 2.4 – '

32

2.2.7 5 5" – TreeView

9 TreeView -

( . =

^ ( ^ . ' ( ( «'», ( ]

( . . 2.4).

Y ] -'^. ^ «Desktop», -

] .

( ] .

, , -

. o

, : «h » «h-

», ListView TreeView. -

( - . '

ListView TreeView. h 2# Windows- ^ Vie-

wapp. h + ( . 2.5):

ListView;

TreeView;

Button – ;

TextBox.

? 2.5 – ' + Viewapp

33

:

button1:

text — « »

button2:

text — « »

textBox1:

text — «»

( , -

+).

using System;

using System.Drawing; using System.Collections;

using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace Viewapp

{

//<suiranary>

//Summary description for Form1.

//</summary>

public class Form1: System.Windows.Forms.Form

{

private System.Windows.Forms.ListView listView1; private System.Windows.Forms.TreeView treeView1; private System.Windows.Forms.TextBox textBox1; private System.windows.Forms.Button buttonl; private System.Windows.Forms.Button button2; //<summary>

//Required designer variable. //</summary>

private system.ComponentModel.Container components = null; public Forml()

{

//Required for Windows Form Designer support

//

InitializeComponent () ;

//

// rDr: Add any constructor code after initiaiizecomponent

call

//

}

//<summary>

//clean up any resources being used. //</summary>

protected override void Dispose ( bool disposing )

{

if ( disposing )

{

if (components != null)

{

components.Dispose();

}

}

34

base. Dispose ( disposing );

}

#region Windows Form Designer generated code #endregion

//<summary>

//The main entry point for the application,

//</summary>

[Stathread]

static void main ()

{

Application.Run (new Form1());

}

}

}

< + ^. Y

^ h . h

Y +. ' -

] , + button1_Click, h-

+ ^ button1_Click , (.

private void button1_Click(object sender. System.EventArgs e)

{

//T SR T_ < P

int idx;

//Zt^\< R ^ Ts SR T Rs Y'\ TS

Listview.SelectedIndexCollection collection =

listView1.SelectedIndices;

//j SR T Rs Y'\ TS <P\ if (collection.Count == 0)

idx = 0; // Y Z < ^ [ SRl T

//j SR T T Y'\ R \

else

//Y Z < T ^ [ S_ Y'\ P R ^ idx = collection[0];

//P\< SRl < ^ R

listView1.Items.Insert(idx, textBox1.Text);

}

@ ^ . @ (

: «'' ». <

h . < «=». <

h . < «/». <

h . | Y ^ ,

. 2.6. 9 ( . '

.

35

? 2.6 – h

= «=». <

«h». < h . | «h»

«=», «/» ( , -

). { , \ ( ]-

. / «'' », -

«0». < h . | «0» ( «=» «'' ». h

, Y ] ^ .

ListView.SelectedIndexCollection collection = listViewl.SelectedIndices;

9 ListView SelectedIndices -

. @ ( -

, ^ ^ Y Shift

Ctrl.

if(collection.Count = 0 ) idx = 0;

{ , ( -

.

.

else

idx = collection[0];

• \ ( , -

Y . 1 Y ( ( ^

collection [0].

listView1.Items.Insert(idx, textBox1.Text);

{ ] . @ ListView.Items ^ . 8 Insert

36

] . < (

- . ' Y idx ] - ^ . <

( . ' \

2.7.

? 2.7 – ?

2.3 "3 2 3 7

2.3.1/

^ , ^ , ( -

.

2.3.2@ :

:

1.@ , ^

NumericUpDown. ' ^ ProgressBar

( -

^ -

( ), -

. @ +

(

).

2.2 ListView, ( , -

\ Y . @ + .

37

1 :

1. ? , \ ^]

 

 

K

1

 

 

, K – , \ ] .

 

 

 

i +

j

2

i =

1

j =1

 

 

@ + ,

.

2.? Label + . 8

+ . ( (

^ : label1.Location = new Point(x, y); h (

( ] Timer. @ + .

3.@ , ^

NumericUpDown, ^ ProgressBar -

, ^

TrackBar ^ ^ ( ,

. @ + .

4.? + -

, ^ 43

4 2. @ + .

5.? + -

, ^ 41 -

4 2. @ + .

6.? + sin(x), 0<x<2*pi -

pi/6. ? ListView. @ +-

.

7.? + cos(x), 0<x<pi

pi/9. ? ListView. @ +

.

8. ? ,

\ ^]

 

 

 

j =1

(i21)!

, – ,

\ ] . @

+ ,

.

9.? ] -

+ ( ), ,

Y 1000. @ +-

.

38

10.? (,

(, -

ListView. @

ProgressBar. @ + .

2.3.3/+ .

2.3.4@ .

2.4 !4 #"4

2.4.1= .

2.4.2.

2.4.39 .

2.4.49 , \ - ( ^ .

2.4.5@, \

(5 Y. ), ( ( ^ -

.

2.5 6^ 4 # 7 2

2.5.1Label?

2.5.2LinkLabel?

2.5.3' Label LinkLabel.

2.5.4' TrackBar.

2.5.5TrackBar?

2.5.6@ ] Pro-

gressBar?

2.5.7ProgressBar?

2.5.8< \ NumericUpDown?

2.5.9NumericUpDown?

2.5.10ListView?

2.5.11TreeView?

2.5.12< ListView

TreeView.

2.5.13• ^] ListView?

2.5.14• ^] TreeView?

2.5.15• ^] Y ListView?

39

3 B 9 9 9 B 3 9 B 9a

3.1 5 7

< ^ Visual Studio.

3.2 " 4 5 5 7K 4 "43 ! 4

2# ] . S Y

, 2# ^] `], \ ^ ^^

^, Y.

3.2.1 67" 4 7 System.String

2# ^] , ] , (-

. 9 ( '] – -

Unicode. 1 Y (, , ^^ , -

^ ^, Y ^ - Y (.

/ Y 2# ] ^ ^

string. @ + ] Y ']

System.String, \ ] , \ ^

.NET Framework ^ . 2# – ']

System.String.

/ Y System.String :

public sealed class String: IComparable, ICloneable, IConvertible, IEnumerable

= Y , \ - ( String. 9 ( ]

+ – IComparable, ICloneable, IConvertible IEnu r bl , ^ + ( System.String

Y .NET Framework.

1 + IComparable ] , \ ] ,

( . ?, , (

Y ^; - ( - Y , \ , Y

40

. IComparable ^

2r T .

IEnumerable + ] ^ foreach, \ .

ICloneable '] ( ^ ']

( , .

( , \ (

, . ICloneable ^

Clone().

IConvertible ^ Y -

'] Y , ToInt32 (), ToDouble (), ToDecimal() . .

3.2.2 " 5 2 2384"

< Y ] , \ , , -

, string:

string newstring = "y SRl Z";

( ( «\n»

«\t», ^ (\) ^ -

. /

] ,

URL Y ,

Y .

? ( ( ^ -

. = (@), -

] String, \

, \ ^ ] ( . -

, ,

^ . = ,

:

String stringOne = "\\\\Mysystem\\Mydirectory\\MyFile.txt"; String stringTwo=@"\\Myfileem\MyDirectory\MyFile.txt";

Y ] ,

\ (\) ^. { - ], \ ( (\) (\\).

] , \ -

.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]