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