advanced vb: object oriented programming - controls

10
OBJECT ORIENTED PROGRAMMING CONTROLS Advanced Visual Basic

Upload: robertbenard

Post on 22-May-2015

1.686 views

Category:

Education


0 download

DESCRIPTION

Object oriented programming - creating custom controls and creating controls at runtime.

TRANSCRIPT

Page 1: Advanced VB: Object Oriented Programming - Controls

OBJECT ORIENTED PROGRAMMINGCONTROLS

Advanced Visual Basic

Page 2: Advanced VB: Object Oriented Programming - Controls

Overview

Visual Basic has many features that allow you to dynamically create controls and programs.  For example, you can create your own objects in Visual Basic that can be used in many applications, just like DLLs.  You can also create controls at runtime. 

Page 3: Advanced VB: Object Oriented Programming - Controls

Controls at run-time

There are instances where the number of controls needed at run-time is variable. Consider displaying images on a scrollable form where the user can add as many images as they desire.

Example:

An instance that I use is for scheduling of classes/space. (see next slide)

Page 4: Advanced VB: Object Oriented Programming - Controls

Controls at run-time (example)

This application reads from a database, creates labels that are sized based on time , and places them on the screen based on start time and location. If there is a double booking in a classroom, the label is made red. This shows the layout of classes for degree flow and space usage.

Page 5: Advanced VB: Object Oriented Programming - Controls

Controls at run-time

Creating a control at run-time

Dim txtBox as new TextBox()txtBox.Text = “I am a textbox”txtBox.Location = New System.Drawing.Point(10, 55) txtBox.Size = New System.Drawing.Size(130, 95)

Page 6: Advanced VB: Object Oriented Programming - Controls

Controls at run-time

Question:

Name some other instances where creating controls at run-time would be useful.

Page 7: Advanced VB: Object Oriented Programming - Controls

Custom/Composite Controls

Composite controls provide a means by which custom graphical interfaces can be created and reused.

A composite control is essentially a component with a visual representation. As such, it might consist of one or more Windows Forms controls, components, or blocks of code that can extend functionality by validating user input, modifying display properties, or performing other tasks required by the author.

Composite controls can be placed on Windows Forms in the same manner as other controls.

Page 8: Advanced VB: Object Oriented Programming - Controls

Custom/Composite Controls

Custom controls are like DLLs. You create these and then apply them to other applications (as many as you like).

There are companies that focus on creating custom controls and sell them to developers.

Example:

ActiveBarCode.com

Page 9: Advanced VB: Object Oriented Programming - Controls

Custom/Composite Controls

Question:

What custom controls might you create?

Page 10: Advanced VB: Object Oriented Programming - Controls

Additional Information

For additional information about these topics, please review your text and the links provided in Blackboard.