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

OPI_LR2011_ch2m1

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

11

using System.Windows.Forms; using System.Data; namespace TestButtons { //<summary>

// summary description for Form1. //</summary>

public Class TestButtonsForm: System.Windows.Forms.Form

{

private System.Windows.Forms.Button button1; private System.Windows.Forms.Groupbox groupBox1;

private System.Windows.Forms.RadioButton radioButton1; private System.Windows.Forms.RadioButton radioButton2;

private System.Windows.Forms.RadioButton radioButton3; private System.Windows.Forms.CheckBox checkBox1;

//< summary >

//Required designer variable.

//</summary >

private System.ComponentModel.Container components = null; public stButt nsF r< ()

{

//

//Required fcr 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.Dispose();

}

}

base.Dispose ( disposing );

}

#region Windows Form Designer generated code //<summary>

//Required method for Designer support - do not motify

//the contents of this method with the code editor.

//</ summary >

private void InitializeComponent ()

(

this.button1 = new System.Windows.Forms.Button (); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.radioButton3 = new System.Windows.Forms.RadioButton ();

12

this.radioButton2 = new System.Windows.Forms.RadioButton (); this.radioButton1 = new System.Windows.Forms.RadioButton (); this.checkBoxl = new System.Windows.Forms.CheckBox(); this.groupBox1.SuspendLayout();

this.SuspendLayout ();

//

//button1

//

this.button1.Location = new System.Drawing.Point(80, 240); this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(128, 23); this.button1.TabIndex = 0;

this.button1.Text = "O PQP R ST <";

//

//groupBox1

this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[]{ this.radioButton3,

this.radioButton2,

this.radioButton1});

this.groupBox1.Location = new System.Drawing.Point (18, 16); this.groupBox1.Name = "groupBox1";

this.groupBox1.Size = new System.Drawing.Size(280, 112); this.groupBox1.TabIndex = 1;

this.groupBox1.TabStop = false;

this.groupBox1.Text = "XRY ZT [ ST <";

//radioButton3

//

this.radioButton3.Location = new System.Drawing.Point (16, 80); this.radioButton3.Name = "radioButton3" ; this.radioButton3.Size = new System.Drawing.Size(240, 24); this.radioButton3.TabIndex = 2;

this.radiobutton3.Text = "Z \ ST <";

//

//radioButton2

this.radioButton2.Location = new System.Drawing.Point (16, 52); this.radioButton2.Name = "radioButton2";

this.radioButton2.Size = new System.Drawing.Size (240, 24); this.radioButton2.TabIndex = 1;

this.radioButton2.Text = "Z^_ ST <";

//radioButton1

//

this.radioButton1.Location = new System.Drawing.Point (16, 24); this.radioButton1.Name = "radioButton1"; this.radioButton1.Size = new System.Drawing.Size (240, 24); this.radioButton1.TabIndex = 0;

this.radioButton1.Text = "Z` ST <";

//

// checkBox1

//

13

this.checkBox1.Checked = true;

this.checkBox1.CheckState = System.Windows.Forms.Checkstate.Checked; this.checkBox1.Location = new System.Drawing.Point(24, 136); this.checkBox1.Name = "checkBox1";

this.checkBox1.Size = new System.Drawing.Size(256, 24); this.checkBox1.TabIndex = 2;

this.checkBox1.Text = "O PQ^SP R ST <";

//

//TestButtonsForm

this.AutoScaleBaseSize = new System.Drawing.Size(5, 131; this.ClientSize = new System.Drawing.Size(292, 273); this.Controls.AddRange(new System.Windows.Forms.Control[] f this.checkBox1,

this.groupBox1,

this.button1});

this.Name = "TestButtonsForm"; this.Text = " "; this.groupBox1.Resumelayout(false); this.ResumeLayout(false) ;

}

#endregion

//<summary>

//The main entry point for the application.

//</summary>

[StathRead]

Static void main() { Application.Run (new Form1 ());

}

}

}

@ Y ( (

C#.

@' +,

. '],

Form1 TestButtonsForm.

Application.Run (new Form1 () ) ;

(\ ]) -

:

Application.Run(new TestButtonsForm());

= . • \ (

, . @-

^ . ' -

. € + ^, + ^-

^ button1. @ ' -

] + – button1_Click, \ Visual

14

Studio.NET. ' + ^ InitializeComponent -

:

this.button1.Click += new System.EventHandler (this.buttonl_Click);

' +:

private void button1_Click(object Sender, System.EventArgs e)

{

}

h + button1_Click :

//SS R< Z S^ Q<T ^

// QY ZT_P YZP_ ST < string strmessage="";

//SRQ PhP\< P P< ZP T P ST Q Ph P //T YRZP\< ST ST i[_

// SRS R<_ ST <

//Z STZ \< Z`^ ZP T ^ if (radioButton1.Checked == true)

{

//j ST <Th P P< i P

// Tk\< R S Q<T ^ strmessage = radioButton1.Text;

}

//Z STZ \< Z^_^ ZP T ^

else if (radioButton2.Checked == true)

{

//j ST Q Ph P P< i P

// Tk\< R S Q<T ^ strmessage = radioButton2.Text;

}

//Z STZ \< Z k ZP T ^

else if (radioButton3.Checked == true)

{

//j ST Q Ph P P< P

// Tk\< R S Q<T ^ strmessage = radioButton3.Text;

}

//Z STZ \<, hR ^ P S Rl h Y, //j QS \ SRST ST <

//j P, SRS R< YZP ST < P ZP if (checkBox1.Checked == true)

{

MessageBox.Show("XR SRYZP R " + strmessage);

}

@ ^ . / Y Y ». < ' . < ' : @ Y . / Y Y , ( Y . = -

15

' . < '-

. < ' . • \ -

^] , ,

.

1.2.5A 65 ""535 2 – Textbox

{ ] -

, \ . @ =xt@ ( -

(. / ] ( – 64

. • \ Y +, \

RichTextBox.

1.2.6 9 #Y7 5 5 65 "" 3 – R4 ht5Zt" Z

h ] (-

Y + (Y 64 ). 9 , RichTextBox ] -, Y +, (. RichTextBox ^ ] (

Microsoft Word.

1.2.7 7 8 – ListBox

– ListBox – Y . @ ] , \ ^

. 9 , ListBox ] ( ( -

. { ] Y

^ ^.

1.2.8 7 8, \ # K ] ^ 2, – CheckedListBox

– , \ ], ]

. † ^ -

16

( . 9 ] (-

, Y -

.

1.2.97 3_K7 7 8 !b BZ

{ , \

] +. ' +

. ' - ( Y . 9 , ( Dropdown ] (

.

? . < Y -, . ' -

– ComboBox, + -

, CheckedListBox, . - ^ ComboBox \ ,

. h + -

.

2 Windows Forms ^ TestLists. - ( Y . ' + Form1.cs TestListsForm.cs. = Y +

( . 1.5):

GroupBox, CheckedListBox;

ComboBox;

Button.

( GroupBox, + +

. / ( \ -

GroupBox . { Y Y

.

17

? 1.5 – ' + TestLists

+: Text – « »

= :

groupBox1:

Text – « »

CheckedListBox: Name – memberlist

comboBox1:

Name – peoplelist

 

Text – «»

button1:

Name – buttonadd

 

Text – «h»

button2:

Text – «@»

| ComboBox CheckedListBox (

^ \ Visual Studio.Net. h ^

Items. @ Items ] . h ] ComboBox, ] ' peoplelist, \ . h

peoplelist Items. @-

String Collection Editor, ( Y -

Items. h \: 1, ', 2 ( . 1.6).

18

? 1.6 – ?

1 , ^ h @-, Y ^ ^ Y ( .

' Y. - ( . = -.

using System;

using System.Drawing; using System.Collections;

using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace TestLists{ //<summary>

//Summary (description for Form1. //</summary>

public Class Form1: System.Windows.Forms.Form{ private System.Windows.Forms.GroupBox groupBox1;

private System.Windows.Forms.CheckedListBox memberlist; private System.Windows.Forms.ComboBox peoplelist; private System.Windows.Forms.Button buttonadd;

private System.Windows.Forms.Button buttondelete;

//<summary>

//Required designer variable.

//</summary>

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

//

// Reqiured for Windows Form Designer Support

//

19

InitializeComponent();

//

// TODO: Add any constructor code after InitializeComponent

call

//

}

//<summary>

//Clean up any resurces being used.

//</summary>

protected override void Dispose ( bool disposing )

{

If ( disposing ) {

if (components != null)

} components.Dispose();

}

base.Dispose ( disposing ) ;

}

#region Widows Form Designer generated code

//<summary>

//Required method for Designer support - do not modify

//the contents of this method with the code editor.

//</summary>

private void InitializeComponent()

{

this.groupbox1 = new System.Windows.Forms.Groupbox(); this.memberlist = new System.Windows.Forms.Checkedlistbox(); this.peoplelist = new System.Windows.Forms.Combobox(); this.buttonadd = new System.Windows.Forms.Button(); this.buttondelete = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout();

this.SuspendLayout ();

//

// groupBox1

//

this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control() {

this.memberlist() ;

this.groupBox1.Location = new System.Drawing.Point (8, 8); this.groupBox1.Name = "groupBox1";

this.groupBox1.Size =new System.Drawing.Size{184, 216); this.groupBox1.TabIndex = 0;

this.groupBox1.TabStop = false; this.groupBox1.Text = "m R ^hP R TS";

//

// memberlist

//

this.memberlist.Location = new System.Drawing.Point(8, 24); this.memberlist.Name = "memberlist";

20

this.memberlist.Size = new System.Drawing.Size(168, 184); this.memberlist.TabIndex = 0;

//

//peoplelist

this.peoplelist.Items.AddRange(new object[] { "nSP S",

"O Z S", "mR Z S"}) ;

this.peoplelist.Location = new System.Drawing.Point(8, 232); this.peoplelist.Name = "peoplelist";

this.peoplelist.Size = new System.Drawing.Size (184, 21); this.peoplelist.TabIndex = 1;

//buttonadd

//

this.buttonadd.Location = new System.Drawing.Point (200, 232); this.buttonadd.Name = "buttonadd";

this.buttonadd.Size = new System.Drawing.Size(80, 23); this.buttonadd.TabIndex = 2;

this.buttonadd.Text = "o P R";

this.buttonadd.Click += new System.EventHandler(thisbuttonadd_Click);

//

//buttondelete

this.buttondelete.Location - new System.Drawing.Point(200, 32); this.buttondelete.Name = "buttondelete";

this.buttondelete.Size = new System.Drawing.Size(80, 23); this.buttondelete.TabIndex = 3;

this.buttondelete.Text = "XR ^hR R"; this.buttondelete.Click += new

System.Eventhandler (this .buttondelete_Click);

//TestListsForm

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size (292, 273); this.Controls.AddRange(new System.Windows.Forms.Control[] ( this.buttondelete,

this.buttonadd,

this.peoplelist, this.groupBox1) ;

this.Name - "TestListsForm"; this.Text = "p Y P QT R P<R"; this.groupBoxl.ResumeLayout(false) ; this.ResumeLayout(false) ;

}

#endregion

//<summary>

//The main entry point for the application.

//</summary>

[Stathread]

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