module 1 window forms – basic, grouping and graphic controls 1

Post on 13-Dec-2015

215 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Module 1

Window Forms – Basic, Grouping and Graphic controls

1

Objective

Overview Window Form and basic Control

Form class

Types of Control

Basic Controls

Grouping an Graphic Controls

2

Application

3

Application

User Interface

-Easy to learn-Easy to use-AttractiveProgram

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

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 ….

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

Use of Controls

7

Control classBase class of all controls available in WinForms

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]

Common Controls

Label

Textbox

Button

ListBox

ComboBox

LinkLabel

9

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

TextBox

CharacterCasing

MaxLength

MultiLine

Name

PasswordChar

ReadOnly

Text

11

AppendText Clear Focus Copy Paste

KeyPress Leave TextChanged

TextBox

Properties Method Event

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

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

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

ListBox

Can select multivalues

15

DisplayMember Items SelectionMode SelectedIndex

• ClearSelected• GetItemText• GetSelected• SetSelected

• SelectedIndexChanged• SelectedValueChanged• ValueMemberChanged

Properties Method Event

ComboBox

DropDownStyle

Items

MaxDropDownItem

SelectedItem

SelectedIndex

Text

ValueMember

16

GetItemText SelectAll Select (int start,

int len)

DropDown SelectedIndexChanged SelectedValueChanged ValueMemberChanged

Properties Method Event

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

Grouping Controls

18

Value Setting ControlForm class

RadioButton

CheckBox

CheckListBox

Grouping Controls

GroupBox

Panel

Images Control

PictureBox

ImageList

RadioButton

Appearance

AutoCheck

Checked

Image

19

PerformClick Select Show

CheckedChanged Click

Properties Method Event

CheckBox

Checked

CheckState

ThreeState

20

Select Show

CheckedChanged CheckStateChange Click

Properties Method Event

CheckedListBox

CheckedIndices

CheckedItems

CheckOnClick

Items

SelectedValue

SelectedItems

SelectedItem

21

ClearSelected GetItemChecked GetItemCheckState GetItemText SetItemChecked SetItemCheckState

ItemCheck MouseClick SelectedIndexChanged SelectedValueChanged

Properties Method Event

Grouping Control

Panel

Contains other Control

GroupBox

As Panel but appear as Frame around Control

22

Panel

AutoSize

AutoSizeMode

BorderStyle

23

Select Show

StyleChanged VisibleChanged

Properties Method Event

GroupBox

AutoSize, Anchor,

FlatStyle

24

Hide, Show

StyleChanged, Resize

Properties

Method

Event

Graphic Controls

PictureBox

Display image on the Form ( .bmp ,.jpg ..)

Can hold sigle image at a time

ImageList

Store collection of images

25

PictureBox

Image

ErrorImage

InitialImage

SizeMode

26

Load LoadAsync

Click Leave LoadCompleted

Properties Method Event

ImageList

Images

ColorDepth

ImageSize

Name

27

Draw RecreateHandle

Properties Method Event

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

top related