Docsity

UI Controls - C Sharp Programming - Lecture Slides, Slides of C Sharp Programming

Partial preview of the text

Download UI Controls - C Sharp Programming - Lecture Slides and more Slides C Sharp Programming in PDF only on Docsity!

UI Controls

Overview

 Image Resources

 The ToolStrip control

 The StatusStrip control

 The TreeView control

 The ListView control

Image Resources (Implementation)

 Use the Select Resource dialog box to select an image

 Images can be used by  The form  The entire project

 Images are stored in a resource file having a suffix of .resx

 Note that resources have many other purposes too  They can store just about anything

The ImageList Control (Introduction)

 Like resource files, it stores images

 It’s used with the TreeView and ListView

control

 Use the Image Collection Editor to assign images to the control

 All images in a control instance must have the same size  If images of multiple sizes are necessary, create multiple control instances

The ImageList Control (Properties)

 The Images collection store a reference to

the images

 Use the Add method to add new images

programmatically  Optional argument contains a string key used to reference the image

 Reference in image  By index  By string key  Calling the IndexOfKey method

The ToolStrip Control (Introduction)

 It replaces the ToolBar control

found in previous versions

 It is considered a container control

meaning that it sites other controls

 Clickable buttons on the toolbar, for example  Events fire as the user interacts with these buttons  The implementation is similar to a menu

The Items Collection (Introduction)

 The Items collection is the container

for the control instances appearing

on the toolbar

 Use the Items Collection Editor to

create these control instances

ToolStripButton , Label , DropDownButton , ComboBox , TextBox , ProgressBar

The Items Collection Editor (Illustration)

The ToolStripButton Class

(Members)

 Set the Image property to the image

that will appear on the button

 Images appear in the folder

 Use Checked and CheckOnClick to

create a checked button

 Use DisplayStyle to display text,

images, or both

The ToolStripDropDownButton

Class

 Use this to create a drop-down

button that works similar to a

combo box

 The DropDownItems collection

contains the items that will drop

down

 Each item has a data type of ToolStripMenuItem  Handle the Click event just like any other menu item

Drill-Down Interface

TreeView utilizes a drill down interface to display file hierarchy

ListView displays files and associated icons

TreeView Control Relationships

 Top-level node is a root node

 Root node has no parent node

 Nodes have one or more children

 Children having the same parent are siblings  One sibling is designated as the first sibling and another as the last sibling

 The terms grandchildren and

great grandchildren further

describe relationships

The TreeView Control

(Properties 1)

 The CheckBoxes property can be set to True or False  If set to True , check boxes appear to the left of each TreeNode  If set to False , they do not

ImageIndex property contains the

numeric index of the image from an associated ImageList control instance

ImageList property contains a reference to an instance of the ImageList control

TreeView Control

(Properties 2)

LabelEdit property ( Boolean ) defines

whether or not the user can edit the textual contents of each TreeNode Nodes property references a collection of TreeNode objects  Note that this collection is hierarchical

Scrollable property ( Boolean ) defines

whether or not scroll bars will appear when the TreeNodes will not fit within the visible region of the control instance