module 1 window forms – basic, grouping and graphic controls 1
TRANSCRIPT
![Page 1: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/1.jpg)
Module 1
Window Forms – Basic, Grouping and Graphic controls
1
![Page 2: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/2.jpg)
Objective
Overview Window Form and basic Control
Form class
Types of Control
Basic Controls
Grouping an Graphic Controls
2
![Page 3: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/3.jpg)
Application
3
Application
User Interface
-Easy to learn-Easy to use-AttractiveProgram
![Page 4: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/4.jpg)
WinForms and .NET Framework
Windows Forms :
are a part of the .NET Framework that is used to build, deploy and run applications.
Provide with a standard programing model in order to create application with least bugs.
Are executed in the .NET CLR runtime.
4
![Page 5: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/5.jpg)
Features
Click one deployment
Application setting
New Windows Forms controls
New Data Binding model
Rich graphics 5
Create App with least operation
Store global data to reuse anywhere
Powerfull way to link control with data source ( BindingSource
component )
GDI+ : drawing and painting image on forms
ToolStrip, MenuStrip ….
![Page 6: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/6.jpg)
Form
Is the basic unit of an application
Presents information to the user
Receives information from the user.
Is represented as a class in the System.Windows.Forms namespace.
6
Properties Text, BackColor, ForeColor, Font, WindowState,AcceptButton, Location, Modal, Name
Methods Activate, Close, Focus, Hide, Show, Enabled
Events Load, Activated,Shown,Deactivate, FormClosing, FormClosed, Resize, Click, GotFocus
![Page 7: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/7.jpg)
Use of Controls
7
Control classBase class of all controls available in WinForms
![Page 8: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/8.jpg)
Control Class
CanFocus
Controls
Enable
Name
Parent
TabIndex
Visible
8
Properties
Focus GetNextControl Hide IsMNemonic Select Show
Method
Click ControlAdd DoubleClick Validating Validated KeyPress Leave LostFocus MouseClick Move
Event
Examplethis.[controlname].[propertyname]
![Page 9: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/9.jpg)
Common Controls
Label
Textbox
Button
ListBox
ComboBox
LinkLabel
9
![Page 10: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/10.jpg)
Label
Name
Text
TextAlign
UseMnemonic
10
Properties
Contains Hide Show
Method
Click
Event
Label fName = new Label();fname.Text = “&First Name : “;fName.UseMnemonic = true ;
Label
![Page 11: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/11.jpg)
TextBox
CharacterCasing
MaxLength
MultiLine
Name
PasswordChar
ReadOnly
Text
11
AppendText Clear Focus Copy Paste
KeyPress Leave TextChanged
TextBox
Properties Method Event
![Page 12: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/12.jpg)
MaskedTextBox
Mask
MaskFull
MaskCompleted
Name
PromptChar
Text
12
GetPositionFromCharIndex
SelectAll
MaskChanged MaskedInputRejected
MaskedTextBox mks = new MaskedTextBox();mks.Mask = “00000-9999”;mks.Text = “095204-7763”;if(!mks.MaskFull){ MessageBox.Show(“Enter proper code …”);}
Properties Method Event
![Page 13: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/13.jpg)
Mask
Mask Description
0 Digit, required. [0-9]
9 Digit or space, optional.
#Digit or space, optional. If this position is blank in the mask, it will be rendered as a space in the property. Plus (+) and minus (-) are allowed.
L Letter, required [a-zA-Z].
? Letter, optional. [a-zA-Z].
& Character, required. If the property = true, behaves like the "L" .
CCharacter, optional. Any non-control character. If the property =true, this element behaves like the "?" element.
AAlphanumeric, optional. If the property =true, the only characters it will accept are the ASCII letters a-z and A-Z.
aAlphanumeric, optional. If the property is set to true, the only characters it will accept are the ASCII letters a-z and A-Z.
13
![Page 14: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/14.jpg)
Button
DialogResult
Enabled
FlatStyle
Image
Name
Text
14
Button cmdOK = new Button();cmdOK .Text = “OK” ; cmdOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
Properties Method Event
Focus PerformClick
Click DoubleClick MouseDoubleClick
Button
![Page 15: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/15.jpg)
ListBox
Can select multivalues
15
DisplayMember Items SelectionMode SelectedIndex
• ClearSelected• GetItemText• GetSelected• SetSelected
• SelectedIndexChanged• SelectedValueChanged• ValueMemberChanged
Properties Method Event
![Page 16: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/16.jpg)
ComboBox
DropDownStyle
Items
MaxDropDownItem
SelectedItem
SelectedIndex
Text
ValueMember
16
GetItemText SelectAll Select (int start,
int len)
DropDown SelectedIndexChanged SelectedValueChanged ValueMemberChanged
Properties Method Event
![Page 17: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/17.jpg)
LinkLabel
17
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 18: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/18.jpg)
Grouping Controls
18
Value Setting ControlForm class
RadioButton
CheckBox
CheckListBox
Grouping Controls
GroupBox
Panel
Images Control
PictureBox
ImageList
![Page 19: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/19.jpg)
RadioButton
Appearance
AutoCheck
Checked
Image
19
PerformClick Select Show
CheckedChanged Click
Properties Method Event
![Page 20: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/20.jpg)
CheckBox
Checked
CheckState
ThreeState
20
Select Show
CheckedChanged CheckStateChange Click
Properties Method Event
![Page 21: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/21.jpg)
CheckedListBox
CheckedIndices
CheckedItems
CheckOnClick
Items
SelectedValue
SelectedItems
SelectedItem
21
ClearSelected GetItemChecked GetItemCheckState GetItemText SetItemChecked SetItemCheckState
ItemCheck MouseClick SelectedIndexChanged SelectedValueChanged
Properties Method Event
![Page 22: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/22.jpg)
Grouping Control
Panel
Contains other Control
GroupBox
As Panel but appear as Frame around Control
22
![Page 23: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/23.jpg)
Panel
AutoSize
AutoSizeMode
BorderStyle
23
Select Show
StyleChanged VisibleChanged
Properties Method Event
![Page 24: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/24.jpg)
GroupBox
AutoSize, Anchor,
FlatStyle
24
Hide, Show
StyleChanged, Resize
Properties
Method
Event
![Page 25: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/25.jpg)
Graphic Controls
PictureBox
Display image on the Form ( .bmp ,.jpg ..)
Can hold sigle image at a time
ImageList
Store collection of images
25
![Page 26: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/26.jpg)
PictureBox
Image
ErrorImage
InitialImage
SizeMode
26
Load LoadAsync
Click Leave LoadCompleted
Properties Method Event
![Page 27: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/27.jpg)
ImageList
Images
ColorDepth
ImageSize
Name
27
Draw RecreateHandle
Properties Method Event
![Page 28: Module 1 Window Forms – Basic, Grouping and Graphic controls 1](https://reader038.vdocuments.net/reader038/viewer/2022110321/56649f505503460f94c729ca/html5/thumbnails/28.jpg)
SplitContainer
Divide the form into two resizable panels
As Window Explorer
28
Properties • BorderStyle• FixedPanel• IsSplitterFixed• Panel1• Panel2• Orientation
Method • OnSplitterMoved• OnSplitterMoving
• Event• SplitterMoved• SplitterMoving• Click