1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type...
-
Upload
maximillian-hardy -
Category
Documents
-
view
234 -
download
6
Transcript of 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type...
![Page 1: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/1.jpg)
1
WinForms – Basic Controls
![Page 2: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/2.jpg)
Objectives
Overview Window Form and basic Control
Form class Type of Control Basic Control Summary
2
![Page 3: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/3.jpg)
Windows Form
3
![Page 4: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/4.jpg)
WinForms and .NET Framework
4
![Page 5: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/5.jpg)
Features
5
Create App with leats operation
Store global data to reused anywhere
Powerfull way to link control with data source ( BindingSource
component)
GDI+ : drawing and painting image on forms
ToolStrip,MenuStrip ….
![Page 6: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/6.jpg)
Form : basic unit of Application
6
![Page 7: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/7.jpg)
Form : property & method
7
![Page 8: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/8.jpg)
Events
8
![Page 9: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/9.jpg)
Life cycle of a form
9
Event
• Activated• Click• Deactivated• FormClosed• FormClosing• GotFocus• Load• Resize
![Page 10: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/10.jpg)
Use of Controls
10
Control classBase class of all
controls available in WinForms
![Page 11: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/11.jpg)
canFocus Controls Enable Name Parent TabIndex Visible
11
Properties
• Focus• getNextControl• Hide• IsMNemonic• Select• Show
Method
• Click• ControlAdd• DoubleClick• Validating• Validated• KeyPress• Leave• LostFocus• MouseClick• Move
Event
Control Class – Properties-Method
![Page 12: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/12.jpg)
Common Controls
12
![Page 13: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/13.jpg)
Label class : Property – Method- Event
NameTextTextAlignUseMnemonic
13
Properties
• Contains• Hide• Show
Method
• Click
Event
Label fname = new Label();fname.Text = “&First Name : “;fname.UseMnemonic = true ;
![Page 14: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/14.jpg)
TextBox & MaskedTextBox
14
![Page 15: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/15.jpg)
TextBox class : Property – Method- Event
CharacterCasing MaxLength MultiLine Name PasswordChar ReadOnly Text
15
Properties
• AppendText• Clear• Focus• Copy• Paste
Method
• KeyPress• Leave• TextChanged
Event
![Page 16: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/16.jpg)
MaskedTextBox class : Property – Method- Event
Mask MaskFull MaskCompleted Name PromptChar Text
16
Properties
• GetPositionFromCharIndex
• IsKeyLock• SelectAll
Method
• MaskChanged• MaskedInputR
ejected
Event
MaskedTextBox mks = new MaskedTextBox();mks.Mask = “00000-9999”;mks.Text = “095204-7763”;if(!mks.MaskFull){
MessageBox.Show(“Enter proper code …”);}
![Page 17: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/17.jpg)
Mask
17
![Page 18: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/18.jpg)
Button class : Property – Method- Event
DialogResult Enabled FlatStyle Image Name Text
18
Properties
• Focus• PerformClick
Method
• Click• DoubleClick• MouseDoubleClick
Event
Button cmdOK = new Button();cmdOK .Text = “OK” ; cmdOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
![Page 19: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/19.jpg)
ListBox & ComboBox
19
ListBox : select multivalue ( 1..N)
ComboBox : select one value at a time
![Page 20: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/20.jpg)
ListBox class : Property – Method- Event
DisplayMember Items SelectionMode SelectedIndex
20
Properties
• ClearSelected• GetItemText• GetSelected• SetSelected
Method
• SelectedIndexChanged
• SelectedValueChanged
• ValueMemberChanged
Event
![Page 21: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/21.jpg)
ComboBox class : Property – Method- Event
DropDownStyle ItemsMaxDropDownItemSelectedItemSelectedIndexTextValueMember
21
Properties
• GetItemText• SelectAll• Select ( int start
, int length)
Method
• DropDown• SelectedIndex
Changed• SelectedValue
Changed• ValueMember
Changed
Event
![Page 22: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/22.jpg)
LinkLabel Control
22
Display a Hyperlink that link to a Web Page or another Window Form
Properties : ActiveLinkColor , Links , LinkColor , LinkVisited, Text , VisitedLinkColor
Method : Select
Event : LinkClicked
![Page 23: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/23.jpg)
Summary – WorkShop Activities
What is WinForm ? Focus on Control TextBox , ListBox , ComBoBox ….
23
![Page 24: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/24.jpg)
Grouping Controls
Value Setting ControlForm class RadioButton CheckBox CheckListBox
Grouping Controls GroupBox Panel
Images Control PictureBox ImageList
Summary
24
![Page 25: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/25.jpg)
Appearance AutoCheck Checked Image
25
Properties
• PerformClick• Select• Show
Method
• CheckedChanged• Click
Event
RadioButton Class – Properties-Method
![Page 26: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/26.jpg)
CheckBox class : Property – Method- Event
CheckedCheckStateThreeState
26
Properties
• Select• Show
Method
• CheckedChanged• CheckStateChange• Click
Event
![Page 27: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/27.jpg)
CheckedListBox class : Property – Method- Event
CheckedIndices CheckedItems CheckOnClick Items SelectedValue SelectedItems SelectedItem
27
Properties
• ClearSelected• GetItemChecked• GetItemCheckState• GetItemText• SetItemChecked• SetItemCheckState
Method
• ItemCheck• MouseClick• SelectedIndexCh
anged• SelectedValueCh
anged
Event
![Page 28: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/28.jpg)
Grouping Control
Panel Contains other
Control GroupBox
As Panel but appear as Frame around Control
28
![Page 29: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/29.jpg)
Panel class : Property – Method- Event
AutoSizeAutoSizeModeBorderStyle
29
Properties
• Select• Show
Method
• StyleChanged• VisibleChanged
Event
![Page 30: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/30.jpg)
GroupBox : Property – Method- Event
AutoSizeAnchorFlatStyle
30
Properties
• Hide• Show
Method
• StyleChanged• Resize
Event
![Page 31: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/31.jpg)
Graphic Controls
PictureBox Display image on the
Form ( .bmp ,.jpg ..) Can hold sigle image
at a time ImageList
Store collection of images
31
![Page 32: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/32.jpg)
PictureBox : Property – Method- Event
ImageErrorImage InitialImageSizeMode
32
Properties
• Load• LoadAsync
Method
• Click• Leave• LoadCompleted
Event
![Page 33: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/33.jpg)
ImageList: Property – Method- Event
ImagesColorDepth ImageSizeName
33
Properties
• Draw
Method
• RecreateHandle
Event
![Page 34: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/34.jpg)
SplitContainer
Divide the form into two resizable panels
As Window Explorer
34
• Properties •BorderStyle• FixedPanel• IsSplitterFixed• Panel1• Panel2• Orientation
Method •OnSplitterMoved• OnSplitterMoving
• Event•SplitterMoved• SplitterMoving• Click
![Page 35: 1 WinForms – Basic Controls. Objectives Overview Window Form and basic Control Form class Type of Control Basic Control Summary 2.](https://reader035.fdocuments.us/reader035/viewer/2022081511/56649f505503460f94c729db/html5/thumbnails/35.jpg)
Summary – WorkShop Activities
35