F -X C h a n ge<br />
<br />
PD<br />
<br />
F -X C h a n ge<br />
<br />
N<br />
<br />
y<br />
<br />
bu<br />
<br />
om<br />
<br />
k<br />
lic<br />
tr<br />
<br />
ac<br />
<br />
.c<br />
<br />
C<br />
<br />
om<br />
<br />
k<br />
lic<br />
C<br />
<br />
.c<br />
<br />
re<br />
<br />
.<br />
<br />
.<br />
<br />
k e r- s o ft w a<br />
<br />
w<br />
<br />
w<br />
<br />
ac<br />
<br />
ww<br />
<br />
ww<br />
<br />
tr<br />
<br />
to<br />
<br />
to<br />
<br />
bu<br />
<br />
y<br />
<br />
N<br />
<br />
O<br />
W<br />
!<br />
<br />
18/05/2011<br />
<br />
O<br />
W<br />
!<br />
<br />
PD<br />
<br />
k e r- s o ft w a<br />
<br />
i dung<br />
<br />
Ch<br />
<br />
ng 6<br />
<br />
CONTROL 2<br />
<br />
y phím<br />
• KeyPress<br />
• KeyDown<br />
• KeyUp<br />
<br />
private void txtgiatri2_KeyPress(object sender, KeyPressEventArgs e)<br />
{<br />
if (e.KeyChar == 27)<br />
private void txtgiatri1_KeyDown(object sender, KeyEventArgs e)<br />
{<br />
{<br />
MessageBox.Show("B n m i gõ phím ESC");<br />
if<br />
} (e.KeyCode == Keys.Escape)<br />
}<br />
MessageBox.Show("Esc");<br />
if (e.KeyData == Keys.Enter)<br />
MessageBox.Show("Enter");<br />
if (e.KeyValue==13)<br />
txtgiatri2.Focus();<br />
<br />
•<br />
•<br />
•<br />
•<br />
•<br />
•<br />
•<br />
•<br />
•<br />
•<br />
•<br />
<br />
y phím<br />
ListBox<br />
ComboBox<br />
CheckedListbox<br />
DateTime / MonthCalendar<br />
NumericUpDown<br />
Menu<br />
i form t form khác<br />
ColorDialog<br />
FontDialog<br />
ToolTip<br />
<br />
ListBox<br />
<br />
• Danh sách ch n a<br />
• Ch ch n 1 trong các ph n<br />
• o p:<br />
<br />
thu c danh sách<br />
<br />
–<br />
nh p (wizard; câu nh)<br />
– Có t CSDL (windows 2)<br />
<br />
}<br />
<br />
1<br />
<br />
re<br />
<br />
F -X C h a n ge<br />
<br />
PD<br />
<br />
F -X C h a n ge<br />
<br />
N<br />
<br />
y<br />
<br />
bu<br />
<br />
Listbox<br />
o listbox<br />
<br />
•<br />
<br />
– Wizard<br />
– Câu l nh<br />
<br />
d ng<br />
<br />
•<br />
<br />
a d li u xu ng bi n<br />
bachoc.Text = gioitinh.SelectedItem.ToString();<br />
– a d li u t textbox lên<br />
t o listbox<br />
listBox1.Items.Add(textBox1.Text);<br />
–<br />
<br />
Ví d<br />
<br />
t s ph<br />
•<br />
•<br />
•<br />
•<br />
•<br />
•<br />
<br />
om<br />
<br />
k<br />
lic<br />
tr<br />
<br />
ac<br />
<br />
.c<br />
<br />
C<br />
<br />
om<br />
<br />
k<br />
lic<br />
C<br />
<br />
.c<br />
<br />
re<br />
<br />
.<br />
<br />
.<br />
<br />
k e r- s o ft w a<br />
<br />
w<br />
<br />
w<br />
<br />
ac<br />
<br />
ww<br />
<br />
ww<br />
<br />
tr<br />
<br />
to<br />
<br />
to<br />
<br />
bu<br />
<br />
y<br />
<br />
N<br />
<br />
O<br />
W<br />
!<br />
<br />
18/05/2011<br />
<br />
O<br />
W<br />
!<br />
<br />
PD<br />
<br />
k e r- s o ft w a<br />
<br />
ng th c<br />
<br />
listBox1.Items.Add(object Item)<br />
listBox1.Items.Clear()<br />
listBox1.Items.RemoveAt(int index)<br />
listBox1.SelectedIndex<br />
listBox1.SelectedItem<br />
listBox1.Items.Count<br />
<br />
Combobox<br />
• Gi ng ListBox<br />
• Sinh viên t nghiên c u<br />
<br />
2<br />
<br />
re<br />
<br />
F -X C h a n ge<br />
<br />
PD<br />
<br />
F -X C h a n ge<br />
<br />
N<br />
<br />
y<br />
<br />
bu<br />
<br />
CheckedListbox<br />
<br />
ac<br />
<br />
.c<br />
<br />
tr<br />
<br />
k e r- s o ft w a<br />
<br />
ol p<br />
•<br />
•<br />
<br />
• Danh sách các a ch n<br />
•<br />
n có th check<br />
t trong nhi u<br />
<br />
om<br />
<br />
k<br />
lic<br />
C<br />
<br />
om<br />
<br />
k<br />
lic<br />
C<br />
<br />
.c<br />
<br />
re<br />
<br />
.<br />
<br />
.<br />
<br />
k e r- s o ft w a<br />
<br />
w<br />
<br />
w<br />
<br />
ac<br />
<br />
ww<br />
<br />
ww<br />
<br />
tr<br />
<br />
to<br />
<br />
to<br />
<br />
bu<br />
<br />
y<br />
<br />
N<br />
<br />
O<br />
W<br />
!<br />
<br />
18/05/2011<br />
<br />
O<br />
W<br />
!<br />
<br />
PD<br />
<br />
d ng wizard<br />
d ng câu l nh<br />
checkedListBox2.Items.Add(textBox2.Text);<br />
<br />
a ch n<br />
<br />
DateTime / MonthCalendar<br />
<br />
Xu t d li u khi s d ng<br />
textBox1.Text = checkedListBox1.SelectedItem.ToString();<br />
foreach ( in )<br />
<br />
•<br />
<br />
string str2="";<br />
foreach (string str1 in checkedListBox1.CheckedItems)<br />
{<br />
str2 += str1 + ",";<br />
}<br />
textBox1.Text = str2;<br />
MessageBox.Show("B n ã ch n " + str2);<br />
<br />
3<br />
<br />
re<br />
<br />
F -X C h a n ge<br />
<br />
PD<br />
<br />
F -X C h a n ge<br />
<br />
N<br />
<br />
y<br />
<br />
bu<br />
<br />
om<br />
<br />
k<br />
lic<br />
tr<br />
<br />
ac<br />
<br />
.c<br />
<br />
C<br />
<br />
om<br />
<br />
k<br />
lic<br />
C<br />
<br />
.c<br />
<br />
re<br />
<br />
.<br />
<br />
.<br />
<br />
k e r- s o ft w a<br />
<br />
w<br />
<br />
w<br />
<br />
ac<br />
<br />
ww<br />
<br />
ww<br />
<br />
tr<br />
<br />
to<br />
<br />
to<br />
<br />
bu<br />
<br />
y<br />
<br />
N<br />
<br />
O<br />
W<br />
!<br />
<br />
18/05/2011<br />
<br />
O<br />
W<br />
!<br />
<br />
PD<br />
<br />
k e r- s o ft w a<br />
<br />
y d li u ra bi n<br />
string st = dateTimePicker1.Value.ToString();<br />
txt2.Text = dateTimePicker1.Value.ToLongDateString();<br />
<br />
y d li u ra bi n<br />
string st2 = monthCalendar1.SelectionRange.ToString();<br />
textBox2.Text = st2;<br />
txt2.Text = monthCalendar1.SelectionStart.ToShortDateString();<br />
<br />
4<br />
<br />
re<br />
<br />
F -X C h a n ge<br />
<br />
PD<br />
<br />
F -X C h a n ge<br />
<br />
N<br />
<br />
y<br />
<br />
bu<br />
<br />
om<br />
<br />
k<br />
lic<br />
tr<br />
<br />
ac<br />
<br />
.c<br />
<br />
C<br />
<br />
om<br />
<br />
k<br />
lic<br />
C<br />
<br />
.c<br />
<br />
re<br />
<br />
.<br />
<br />
.<br />
<br />
k e r- s o ft w a<br />
<br />
w<br />
<br />
w<br />
<br />
ac<br />
<br />
ww<br />
<br />
ww<br />
<br />
tr<br />
<br />
to<br />
<br />
to<br />
<br />
bu<br />
<br />
y<br />
<br />
N<br />
<br />
O<br />
W<br />
!<br />
<br />
18/05/2011<br />
<br />
O<br />
W<br />
!<br />
<br />
PD<br />
<br />
k e r- s o ft w a<br />
<br />
NumericUpDown<br />
•<br />
•<br />
<br />
n giá tr liên c<br />
i giá tr cách nhau 1<br />
<br />
n<br />
<br />
nguyên<br />
<br />
d ng<br />
<br />
Menu<br />
<br />
private void button2_Click(object sender, EventArgs e)<br />
{<br />
numericUpDown1.Value = Convert.ToInt32(textBox4.Text);<br />
numericUpDown1.Maximum = Convert.ToInt32(textBox4.Text);<br />
numericUpDown1.Minimum = 0;<br />
}<br />
private void button3_Click(object sender, EventArgs e)<br />
{<br />
textBox5.Text = numericUpDown1.Value.ToString();<br />
}<br />
<br />
5<br />
<br />
re<br />
<br />