Tải bản đầy đủ (.pdf) (15 trang)

Bài giảng Lập trình C# 1 - Chương 3: Control

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (378.36 KB, 15 trang )

F -X C h a n ge

PD

F -X C h a n ge

N

y

bu

om

k
lic
tr

ac

.c

C

om

k
lic
C

.c



re

.

.

k e r- s o ft w a

w

w

ac

ww

ww

tr

to

to

bu

y

N


O
W
!

12/05/2011

O
W
!

PD

k e r- s o ft w a

i dung

Ch

ng 3

Introduction

CONTROL

Labels,
TextBoxes
and Buttons

GroupBoxes

and Panels

Windows
form

Control
Properties
and Layout

CheckBoxes
and
RadioButtons

PictureBoxes

2

1

1. Introduction

2. Windows form

• Giao di n là ràng bu c, giao c m b o cho các l p
hay các c u trúc s th c hi n m t
u gì ó.

t giao di n a ra m t s thay th cho các l p tr u
ng
t o ra các s ràng bu c gi a nh ng l p và các

thành ph n client c a nó.
• Khi m t l p th c thi m t giao di n, l p này ph i th c thi
t c các ph ng th c c a giao di n. ây là m t b t
bu c mà các l p ph i th c hi n.
• Trong ch ng này chúng ta s th o lu n :
• Cách t o, th c thi và s d ng các giao di n.
• Cách th c thi nhi u giao di n cùng v i cách k t h p
và m
ng giao di n

• Cho phép ng i phát tri n t o ra các giao di n ng i
dùng s d ng các thành ph n khác nhau (components).

t Form
c ch y trên m t máy tính c c b (local
machine) và m t form có th truy c p n các tài
nguyên khác nhau nh b nh , các th m c, các t p tin,
các c s d li u…
• Do ó Windows Form phù h p cho các ng d ng
desktop nh các ng d ng qu n lý thông tin, các ng
ng t ng tác tr c ti p v i ng i dùng.
• Vai trị c a Windows Form:

lý d li u
c nh p b i ng i dùng.
– Hi n th (trình bày) các thơng tin t i ng i dùng.

t n i n các ngu n CSDL khác nhau trên các máy tính c c b
ho c máy tính khác
3


4

1

re


F -X C h a n ge

PD

F -X C h a n ge

N

y

bu

Windows form
tính n ng m i







om


k
lic
tr

ac

.c

C

om

k
lic
C

.c

re

.

.

k e r- s o ft w a

w

w


ac

ww

ww

tr

to

to

bu

y

N

O
W
!

12/05/2011

O
W
!

PD


k e r- s o ft w a

Các tính n ng c a form

ClickOne Deployment: là m t k thu t cho phép t o các ng d ng
mà có th
c cài t v i ít thao tác c a ng i dùng nh t.
Application Settings (các thi t l p ng d ng): tính n ng này cho
phép l u tr các thơng tin tồn c c c ng nh các thông tin liên
quan t i ng i dùng vào trong các ngu n l u tr (file XML, CSDL,
các t p tin…)
New Windows Form Controls: tính n ng này cung c p các
u
khi n m i, cho phép t o ra các ng d ng v i giao di n a d ng,
phong phú h n.
New Data Binding Model (mơ hình liên k t d li u m i): tính này
ng cung c p m t cách n gi n, thu n ti n, m nh m
liên k t
các
u khi n v i m t ngu n d li u
Rich Graphics
h a phong phú): tính n ng này là s m r ng c a
GDI lên GDI+
c s d ng cho vi c v và thao tác v i các hình
nh

• Trong .NET thì
t o m t Windows Form ng a là
o m t i t ng t l p Form


p này n m trong Namespace có tên là
System.Windows.Forms
• Nói cách khác :
p Form là l p tr u t ng hóa t t c các Windows
Form trong các ng d ng.

i m t Windows Form là m t th hi n c th ( i
ng) c a l p Form


6

5

o form


n có th s d ng tính n ng tr c quan
p các
u khi n

• Ch n m c Visual Studio .NET trong menu Start
• File New Project

thi t



n c ng có th s d ng ch c n ng vi t code

t o các
u khi n



n có th k t h p c 2 cách trên khi t o form

7

8

2

re


F -X C h a n ge

PD

F -X C h a n ge

N

y

bu

om


k
lic
tr

ac

.c

C

om

k
lic
C

.c

re

.

.

k e r- s o ft w a

w

w


ac

ww

ww

tr

to

to

bu

y

N

O
W
!

12/05/2011

O
W
!

PD


k e r- s o ft w a

3. Control Properties and Layout

9

10

Chi ti t l p form
















Name
autosize
Text
Width
Height

StartPosition
Location
Left
Top
Right
Bottom
FormBorderStyle
MaximizeBox
MinimizeBoz
Tag



TopMost



Controls

Các ph

tên form
thay i kích th c form
y/thi t l p tiêu
c a Windows Form.
r ng c a Form.
chi u cao c a Form.
ch ra v trí kh i ng ban u c a Form.
ch ra v trí theo t a
x,y.

a
trái.
a
trên.
a
bên ph i.
a
bên d i.
ch ra ki u vi n c a Form.
cho phép hi n th nút phóng to hay ko?
cho phép hi n th nút thu nh ko.
thu c tính này th ng
c s d ng
ính kèm
li u vào Form.
cho phép Form ln
c hi n th trên t t c các
Form khác ko. M c nh là ko (false).
là t p h p các
u khi n trên Form.

• Show
• Hide
• ShowDialog
• Activate

11

ng th c


Hi n th m t Form
n Form
Hi n th Form d i d ng m t h p
tho i
Kích ho t Form

12

3

re


F -X C h a n ge

PD

F -X C h a n ge

N

y

bu

Các s
• Init
• Load

• FormClosing

• FormClosed

ki n

Các

y ra sau khi Form
c t o ra.
y ra khi Form
c n p vào b
nh vào sau ó
c hi n th . S
ki n này là th i
m thích h p
chúng ta l y d li u và gán
cho các
u khi n trên Form.
X y ra tr c khi Form
c óng.
y ra sau khi Form
c óng
và tr c khi Form
c gi i
phóng kh i b nh

ac

.c

tr


k e r- s o ft w a

u khi n

• Basic Controls (các khi n c b n)
• Value Setting Controls (các
u khi n thi t l p
giá tr )
• Selection List Controls (các
u khi n danh sách
ch n)
• Grouping Controls (các
u khi n nhóm)
• Graphics Controls (các
u khi n
h a)

14

13

Quy t t

om

k
lic
C


om

k
lic
C

.c

re

.

.

k e r- s o ft w a

w

w

ac

ww

ww

tr

to


to

bu

y

N

O
W
!

12/05/2011

O
W
!

PD

t tên

4. Labels, TextBoxes and Buttons

• Xem file QuyTacDatTen.pdf

• Labels:
– Các nhãn
– Gi i thích; minh ho


• TextBoxes:
– Dùng nh p li u

• Buttons:
– Các nút

15

u khi n

16

4

re


F -X C h a n ge

PD

F -X C h a n ge

N

y

bu

om


k
lic
tr

ac

.c

C

om

k
lic
C

.c

re

.

.

k e r- s o ft w a

w

w


ac

ww

ww

tr

to

to

bu

y

N

O
W
!

12/05/2011

O
W
!

PD


k e r- s o ft w a

Labels







AutoSize
Backcolor
BorderColor
BorderStyle
Location(X, Y)
Name








Font
ForeColor
Size
TabIndex
Text

TextAlign

18

17

namespace WindowsFormsApplication3
{
partial class Form1code
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
this.label1.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
{
this.AutoScaleDimensions
= new System.Drawing.SizeF(6F, 13F);
this.label1.BorderStyle
=!=System.Windows.Forms.BorderStyle.Fixed3D;
if (disposing
&& (components
null))
this.AutoScaleMode
= System.Windows.Forms.AutoScaleMode.Font;
{
this.label1.ForeColor
=
System.Drawing.SystemColors.MenuHighlight;
this.ClientSize = new System.Drawing.Size(384, 262);
components.Dispose();
this.label1.Location

= new System.Drawing.Point(18, 40);
}
this.label1.Name = "label1";
this.Controls.Add(this.label1);
base.Dispose(disposing);
this.label1.Size = new System.Drawing.Size(100, 15);
}
this.label1.TabIndex
= 4; = new System.Windows.Forms.Label();
this.Name
= "Form1";
this.label1
#region Windows this.label1.Text
Form Designer
generated
code
= b"Ln p1";
CDTH11QN";
this.Text = "Chào
this.SuspendLayout();
private void InitializeComponent()
this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
{
this.ResumeLayout(false);
// nh ngh
a label
this.PerformLayout();
//l nh khai
báo các trình bày
//khai báo label

private
//khai báo form System.Windows.Forms.Label label1;
}
#endregion
// nh ngh a label trong l p riêng
}
}

code

19

TextBoxes



i
a d li u vào bi n nh
i
a d li u t bi n nh ra hi n th (ít s
ng)

20

5

re


F -X C h a n ge


PD

F -X C h a n ge

N

y

bu


nh ngh a
• Khai báo:
Font
Color
Point
Multiline
Name
Enabled
Size
TabIndex

1.
2.

L y d li u t textbox

ac


.c

tr

k e r- s o ft w a

namespace WindowsFormsApplication3
{
partial class Form1code
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
// nh ngh a TextBox

TextBoxes











om

k
lic
C

om

k
lic
C

.c

re

.

.

k e r- s o ft w a

w

w


ac

ww

ww

tr

to

to

bu

y

N

O
W
!

12/05/2011

O
W
!

PD


a vào bi n nh

a d li u t bi n nh lên textbox

//l nh khai báo các trình bày
//khai báo TextBox
//khai báo form, kích ho t textbox
}
#endregion
// nh ngh a text trong l p riêng

• Kích ho t
• Khai báo bi n riêng
}
}

22

21

this.txtso1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
this.txtso1.Font = new System.Drawing.Font("Times New Roman", 18F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((byte)(0)));
this.txtso1.ForeColor = System.Drawing.Color.Maroon;
this.txtso1.Location = new System.Drawing.Point(162, 103);
this.txtso1.Name = "txtso1";
this.txtso1.Size = new System.Drawing.Size(70, 35);

this.txtso1.TabIndex = 5;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(384, 262);
this.Controls.Add(this.txtso1);
this.Name = "Form1";
this.Text = "Chao ban!";
this.ResumeLayout(false);
this.PerformLayout();
private System.Windows.Forms.TextBox txtso1;
23

lý d


y d li u t textbox

li u
a vào bi n nh :

so2 = Convert.ToInt32(txtso2.Text);
ho c
so1=Int32.Parse(txtso2.Text)



a d li u t bi n nh lên textbox:
Console.WriteLine("Tong cua so "+intso1+" va so "+intso2+" la "+inttong);

ho c

txtso3.Text = "" + so3;

24

6

re


F -X C h a n ge

PD

F -X C h a n ge

N

y

bu

Buttons
• Nút xác nh các

o Buttons:

om

k
lic

tr

ac

.c

C

om

k
lic
C

.c

re

.

.

k e r- s o ft w a

w

w

ac


ww

ww

tr

to

to

bu

y

N

O
W
!

12/05/2011

O
W
!

PD

k e r- s o ft w a


nh ngh a

ki n liên quan

this.bttinh = new System.Windows.Forms.Button();

– nh ngh a
– Khai báo

• Thu c tính

ki n (events)
– Kích ho t
– Khai báo button thu c

p riêng

26

25

Thu c tính

Ph

this.bttinh.Font = new System.Drawing.Font("Times New Roman", 14F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((byte)(0)));
this.bttinh.ForeColor = System.Drawing.Color.Red;
this.bttinh.Location = new System.Drawing.Point(283, 103);

this.bttinh.Name = "bttinh";
this.bttinh.Size = new System.Drawing.Size(66, 28);
this.bttinh.TabIndex = 8;
this.bttinh.Text = "Tính";
this.bttinh.UseVisualStyleBackColor = true;
this.bttinh.Click += new System.EventHandler(this.bttinh_Click);

27

ng th c và s

ki n

• Focus: Cho phép thi t l p khi kh i t o Form u
tiên
u khi n TextBox
• Click:

y ra khi

u khi n Button

c nh n

• Command: y ra khi
u khi n Button
c
nh n. CommandName và CommandArgument
c truy n qua s ki n


28

7

re


F -X C h a n ge

PD

F -X C h a n ge

N

y

bu

Xác

nh events

om

k
lic
tr

ac


.c

C

om

k
lic
C

.c

re

.

.

k e r- s o ft w a

w

w

ac

ww

ww


tr

to

to

bu

y

N

O
W
!

12/05/2011

O
W
!

PD

k e r- s o ft w a

Kích ho t trong form

private void bttinh_Click(object sender, EventArgs e)


this.Controls.Add(this.lbtong);

{
int so1, so2, so3;
so1 = Convert.ToInt32(txtso1.Text);
so2 = Int32.Parse(txtso2.Text);
so3 = so1 + so2;
txtso3.Text = Convert.ToString(so3);
}

“" + so3;
30

29

Khai báo button trong l p riêng

5. GroupBoxes and Panels

private System.Windows.Forms.Button bttinh;

• Groupboxes:
– Vùng nhóm các trình bày
– Thơng th ng GroupBoxes s ch a:

• RadioButton
• CheckBox
• Panels:
– Vùng giao di n

– Ch a nhi u i t

31

ng

32

8

re


F -X C h a n ge

PD

F -X C h a n ge

N

y

bu

om

k
lic
tr


ac

.c

C

om

k
lic
C

.c

re

.

.

k e r- s o ft w a

w

w

ac

ww


ww

tr

to

to

bu

y

N

O
W
!

12/05/2011

O
W
!

PD

k e r- s o ft w a

GroupBoxes

namespace WindowsFormsApplication5
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.SuspendLayout();
// groupBox1
// Form1
}
#endregion
private System.Windows.Forms.GroupBox groupBox1;
}
}
34

33

// groupBox1


// Form1

this.groupBox1.BackColor =
System.Drawing.Color.FromArgb(((int)(((byte)(192)))),
((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.groupBox1.Location = new System.Drawing.Point(97,
42);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(241, 119);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Nhóm cơng vi c";

this.AutoScaleDimensions = new System.Drawing.SizeF(6F,
13F);
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(584, 364);
this.Controls.Add(this.groupBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

35

36

9


re


F -X C h a n ge

PD

F -X C h a n ge

N

y

bu

om

k
lic
tr

ac

.c

C

om

k

lic
C

.c

re

.

.

k e r- s o ft w a

w

w

ac

ww

ww

tr

to

to

bu


y

N

O
W
!

12/05/2011

O
W
!

PD

k e r- s o ft w a

Panels
namespace WindowsFormsApplication5
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();

}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.SuspendLayout();
// panel1
// Form1
}
#endregion
private System.Windows.Forms.Panel panel1;
}
}
37

38

// panel1

// Form1

this.panel1.AutoScroll = true;
this.panel1.BackColor =
System.Drawing.SystemColors.ActiveCaption;
this.panel1.Location = new System.Drawing.Point(34, 152);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(448, 189);
this.panel1.TabIndex = 1;


this.AutoScaleDimensions = new System.Drawing.SizeF(6F,
13F);
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(584, 364);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

39

40

10

re


F -X C h a n ge

PD

F -X C h a n ge

N

y


bu

6. CheckBoxes and RadioButtons

ac

.c

tr

k e r- s o ft w a

CheckBoxes
namespace WindowsFormsApplication5
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.checkBox1 = new System.Windows.Forms.CheckBox();

this.SuspendLayout();
// checkBox1
// Form1
}
#endregion
private System.Windows.Forms.CheckBox checkBox1;
}
}

• CheckBoxes:
– Có nhi u l a ch n
– n
c phép:
• Ch n 1 ho c nhi u h n 1
• Ch n t t c
• Khơng ch n

• RadioButtons
– Có nhi u l a ch n
– n ch
c ch n 1 mà thơi



om

k
lic
C


om

k
lic
C

.c

re

.

.

k e r- s o ft w a

w

w

ac

ww

ww

tr

to


to

bu

y

N

O
W
!

12/05/2011

O
W
!

PD

d ng CheckBoxes và RadioButtons
41

// checkBox1

42

// Form1
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(519, 364);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.panel1);
this.Controls.Add(this.groupBox1);
this.Name = "Form1";
this.Text = "Form1";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.ResumeLayout(false);

this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(33,
18);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(48, 17);
this.checkBox1.TabIndex = 0;
this.checkBox1.Text = "Nam";
this.checkBox1.UseVisualStyleBackColor = true;

43

44

11

re



F -X C h a n ge

PD

F -X C h a n ge

N

y

bu

// groupBox2

om

k
lic
tr

ac

.c

C

om

k
lic

C

.c

re

.

.

k e r- s o ft w a

w

w

ac

ww

ww

tr

to

to

bu


y

N

O
W
!

12/05/2011

O
W
!

PD

k e r- s o ft w a

RadioButtons

this.groupBox2.Controls.Add(this.checkBox2);
this.groupBox2.Controls.Add(this.checkBox1);
this.groupBox2.Location = new System.Drawing.Point(233,
28);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(108, 81);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Gi i tính";


namespace WindowsFormsApplication5
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.SuspendLayout();
// radioButton1
// Form1
}
#endregion
private System.Windows.Forms.RadioButton radioButton1;
}
}

45

46


// radioButton1

// Form1

this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(37,
25);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(77, 17);
this.radioButton1.TabIndex = 0;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "Nh p
m";
this.radioButton1.UseVisualStyleBackColor = true;

this.AutoScaleDimensions = new System.Drawing.SizeF(6F,
13F);
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(519, 364);
this.Controls.Add(this.groupBox1);
this.Name = "Form1";
this.Text = "Form1";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);

47

48


12

re


F -X C h a n ge

PD

F -X C h a n ge

N

y

bu

// groupBox1

om

k
lic
tr

ac

.c


C

om

k
lic
C

.c

re

.

.

k e r- s o ft w a

w

w

ac

ww

ww

tr


to

to

bu

y

N

O
W
!

12/05/2011

O
W
!

PD

k e r- s o ft w a

d ng RadioButton và Checkbox

this.groupBox1.BackColor =
System.Drawing.Color.FromArgb(((int)(((byte)(192)))),
((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.groupBox1.Controls.Add(this.radioButton4);

this.groupBox1.Controls.Add(this.radioButton3);
this.groupBox1.Location = new System.Drawing.Point(34, 27);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(160, 83);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Nhóm cơng vi c";



c ích:
– Ki m sốt ng i dùng click vào nút nào
– Xác nh hành ng ti p theo là gì

• Câu l nh:
radioButton3.Checked == true / false
checkBox1.Checked == true / false
49

50

private void button1_Click(object sender, EventArgs e)
{
if (radioButton3.Checked==true)
congviec.Text="Nh p
m";
if (radioButton4.Checked == true)
congviec.Text = "Tính
m";
if (checkBox1.Checked == true)

gioitinh.Text = "Ng i Nam";
if (checkBox2.Checked == true)
gioitinh.Text = "Ng i N ";
if ((checkBox1.Checked==true) && (checkBox2.Checked==true))

gioitinh.Text="Nam và N ";

if ((checkBox1.Checked == false) && (checkBox2.Checked == false))

}

51

gioitinh.Text = "";

52

13

re


F -X C h a n ge

PD

F -X C h a n ge

N


y

bu

7. PictureBoxes

om

k
lic
tr

ac

.c

C

om

k
lic
C

.c

re

.


.

k e r- s o ft w a

w

w

ac

ww

ww

tr

to

to

bu

y

N

O
W
!


12/05/2011

O
W
!

PD

k e r- s o ft w a

7. PictureBoxes







AnchorStyles
Name
BackColor
Image
Size
SizeMode

53

7. PictureBoxes

54


n event khi click vào nh

this.anh1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.anh1)).BeginInit();
this.SuspendLayout();
// anh1
this.anh1.Anchor =
((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.To
p | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.anh1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.anh1.Image = global::Control.Properties.Resources.IMG_3264;
this.anh1.Location = new System.Drawing.Point(44, 50);
this.anh1.Name = "anh1";
this.anh1.Size = new System.Drawing.Size(155, 143);
this.anh1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.anh1.TabIndex = 0;
this.anh1.TabStop = false;

55

private void pictureBox1_Click(object sender, EventArgs e)
{
//Câu l nh
MessageBox.Show("B n ã ch n hoa t tr ng");
}

56


14

re


F -X C h a n ge

PD

F -X C h a n ge

N

y

bu

om

k
lic
tr

ac

.c

C


om

k
lic
C

.c

re

.

.

k e r- s o ft w a

w

w

ac

ww

ww

tr

to


to

bu

y

N

O
W
!

12/05/2011

O
W
!

PD

k e r- s o ft w a

Hi n th t ng nh trong picturebox
private void button1_Click(object sender, EventArgs e)
{
imageNum = imageNum + 1;
if (imageNum > 3)
imageNum = 1;
pictureBox1.Image =
Image.FromFile("D:/GIANGDAY/C#/Csharp_Basic/MINHHO

A/picture/anh" + imageNum + ".jpg");
}

57

Thanks

58

15

re



×