YOMEDIA
Lecture Windows programming: Chapter 3(2) - Châu Thị Bảo Hà
Chia sẻ: Kiếp Này Bình Yên
| Ngày:
| Loại File: PPTX
| Số trang:33
66
lượt xem
3
download
Download
Vui lòng tải xuống để xem tài liệu đầy đủ
Chapter 3 (Cont’d) introduction to the Windows programming. In this chapter present the some common controls as: Button; label, LinkLabel; TextBox ( + ErrorProvider component), RichTextBox; GroupBox, panel; CheckBox, RadioButton; PictureBox, ImageList;... Inviting you to refer.
AMBIENT/
Chủ đề:
Nội dung Text: Lecture Windows programming: Chapter 3(2) - Châu Thị Bảo Hà
- Chapter 3
Windows
Programming
Cont’d
1
- Contents
•
Introduction to Windows Form Application
•
Introduction to Form
•
Introduction to Control
•
Events
•
Some common Controls
•
Some advanced Controls
Slide 2
- Naming rules
•
Each control has an identifier (Name
property)
– can contain letters, digits, and underscores (_)
– cannot start with digits
– can start with the @ symbol
– no spaces or punctuation marks
•
If multiple words capitalize 1st letter of each
word
•
3 letter lowercase prefix identifies control
type Slide 3
- Recommended naming
Object Class Prefix Example
Form frm frmDataEntry
Button btn btnExit
TextBox txt txtPaymentAmount
Label lbl lblTotal
RadioButton rad radBold
CheckBox chk chkPrintSummary
PictureBox pic picLandscape
ComboBox cbo cboBookList
ListBox lst lstIndegredients
GroupBox grb grbColor
Slide 4
- Some common Controls
1. Button
2. Label, LinkLabel
3. TextBox ( + ErrorProvider component),
RichTextBox
4. GroupBox, Panel
5. CheckBox, RadioButton
6. PictureBox, ImageList
7. ListBox, CheckedListBox
8. ComboBox
Slide 5
- Button (p.453)
•
Allows the user to click it to perform an
action
– some properties:
•
FlatStyle
•
Image
•
ImageAlign
•
Text
•
TextAlign
– default event:
•
Click event: happens whenever a user clicks the
button Slide 6
- Label (p.456)
•
To display text or images that cannot be
edited by the user
– some properties:
•
AutoSize
•
BorderStyle
•
Font
•
Image
•
ImageAlign
•
Text
•
TextAlign
Slide 7
- LinkLabel (p.456)
•
To add Web-style links to applications
– some properties:
•
ActiveLinkColor
•
LinkArea
•
LinkColor
•
LinkVisited
•
VisitedLinkColor
Slide 8
- TextBox (p.457)
•
To enter text or display information
– some properties:
•
CausesValidation: true/false
•
CharacterCasing: Normal/Upper/Lower
•
MaxLength
•
Multiline: true/false
•
PasswordChar
•
ReadOnly: true/false
•
ScrollBars
•
WordWrap: true/false Slide 9
- TextBox (cont.)
– some events:
•
TextChanged
•
Enter
•
Leave These events occur in this order
•
Validating
•
Validated
KeyDown and KeyUp receive the key code
•
KeyDown corresponding to the key that was pressed.
KeyPress receives the character corresponding to a
•
KeyPress keyboard key.
•
KeyUp
•
Try it out - Working with a TextBox Slide
Control
10
- The ErrorProvider component
•
You can display an error to alert the user
about invalid data input by using
ErrorProvider component
•
BlinkRate property
•
BlinkStyle property
•
ContainerControl property
•
GetError() method
•
Icon property
•
SetError() method
•
SetIconAlignment() method
•
SetIconPadding() method
Slide 11
- Demo: Validating and Validated
event
•
Example:
private void txtNumber1_Validating(object sender, CancelEventArgs
e) {
if (Convert.ToInt32(txtNumber1.Text) < 0) {
e.Cancel = true; // cancel the event
errorProvider1.SetError(txtNumber1, “this is not a valid number");
txtNumber1.SelectAll();
}
}private void txtNumber1_Validated(object sender,
EventArgs e) {
errorProvider1.SetError(txtNumber1, "");
Slide 12
- Demo: Validating and Validated
event
Slide 13
- Demo: KeyPress event
Slide 14
- RichTextBox (p.470)
•
Used for displaying, entering, and
manipulating text with more formatting
(display fonts, colors, and links; load text
and embedded images from a file; undo
and redo editing operations; and find
specified characters)
– some properties (p.471):
•
SelectedText
•
SelectionAlignment
•
SelectionColor
•
SelectionFont Slide 15
- GroupBox, Panel
•
Arrange components on a GUI
– GroupBox can display a caption (p.466)
•
Text property: determines its caption
– Panel can have scrollbar
•
AutoScroll property
•
BorderStyle property
Slide 16
- RadioButton
•
RadioButton (p.465):
– is used to give users
a choice between
two or more mutually
exclusive options
– use a GroupBox
control or some other
container to group
radio buttons
together
•
if radio buttons are
placed within a form,
Slide 17
- RadioButton (cont.)
– some properties:
•
Appearance: Normal/Button
•
AutoCheck: When false, the radio button must be
manually checked in code from the Click event
handler
•
Checked: True/False
•
CheckAlign
– some events:
•
CheckedChanged: occurs when the check of the
RadioButton changes (default)
•
Click: occurs every time the RadioButton is clicked
Slide 18
- CheckBox
•
CheckBox (p.466)
– is used to enable users to choose one or more
options
– a check box can have three states: Checked,
Indeterminate and Unchecked
– some properties:
•
CheckState: Checked/Indeterminate/Unchecked
•
Checked: True/False
•
ThreeState: When false, the user will not be able to
change the CheckState state Try
to Indeterminate
it out p.467
(except by coding)
Slide 19
- PictureBox
•
To display graphics in bitmap, GIF, JPEG,
metafile, or icon format
– Image property
– SizeMode property
– Click event
•
To load image from file by coding, using:
– pictureBox1.Image = Image.FromFile("path");
Example: pictureBox1.Image =
Image.FromFile("d:\\Hinh\\myPic.jpg");
• Slide 20
Thêm tài liệu vào bộ sưu tập có sẵn:
Báo xấu
LAVA
ERROR:connection to 10.20.1.98:9315 failed (errno=111, msg=Connection refused)
ERROR:connection to 10.20.1.98:9315 failed (errno=111, msg=Connection refused)
Đang xử lý...