Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

Visual Programming – Unit II

3. Menus, Mouse Events andDialogBoxes


3.1 Menus
VB offers applications can be enhanced by adding menus to it. It offers a convenient and consistent way
to group commands and an easy way for users to access them. The menubar appears below the title bar and it
may contain one or more menu titles. When a menu title is clicked it displays a set of menu items under that
title (for e.g. Exit, Open). Each menu item corresponds to a menu control that is defined in a menu editor and
performs a specific action.

Using the Menu Editor


A menu editor can be used to add new commands to the exiting menus, create new menus and menu
bars, change or delete exiting menu and menu bars. A menu editor can be added only after opening a project. To
display menu editor, Menu Editor Command is chosen from the Tools menus or the menu editor is clicked this
is in the toolbar. Below figure displays a menu Editor. The menu editor includes all the menu controls of the
current form. The properties of all the menu items are available in the properties window.

Writing a Program
Develop an application for the supermarket SM & CO, when the label tags for the items have to be
obtained in different colours and size.

A program contains a menu bar with two titles: Colours and Size. The Colours menu allows selection of a
colour from a menu and files the program's Form with the selected colour. The Colours menu has menu items
Fillcolour and Exit. When the FillColour menu is clicked another menu pops up with a list of colours. This is a
submenu of the menu FillColour. A menu item can have a maximum of four levels of submenus. The Form of
the program is filled with the selected colour from the popup menu. The Size menu contains menu items Small
and Large.

Dept. of Computer Science, BCAS, Erode 33


Visual Programming – Unit II

Example
 A new Standard EXE project is opened and the Form and the project files are saved as Colours.frm and
Colours.vbp.
 The Form is designed as per the properties table given below
Object Property Settings
Form Caption COLOUR / SIZE
Name frmColour
The menu items are for the Form is designed as per the following specification listed below:
Object Settings
&Colours mnucolour
...&Fill Colour mnuFillColour
......&Red mnuRed
......&Green mnuGreen
......&Blue mnuBlue
&Size mnuSize
... &Small mnuSmall
...&Large mnuLarge
The following steps are performed to create the full menu application.
 After selecting the Menu Editor, &Colours is typed in the Caption TextBox and mnucolour in the Name
TextBox. The '&' character underlines the letter C. This property allows to us to press Alt + C while the
program is running which has the same effect of clicking Colours.

 The Next button is clicked and &FilI Colour is typed in the Caption TextBox and mnuFillColour in the
Name TextBox. The right arrow button is now clicked.
 The Next button is clicked and &Exit is typed in the Caption TextBox and mnuSize the Name TextBox.
The left arrow button is now clicked.
 The Next button is clicked and &Size is typed in the Caption TextBox and mnuSize in the Name TextBox.
The left arrow button is now clicked.

Dept. of Computer Science, BCAS, Erode 34


Visual Programming – Unit II

 Now the next button is clicked and S&maIl is typed in the Caption TextBox and mnuSamll in the Name
TextBox. The right arrow is clicked.
 The Next button is clicked and &Large is typed in the Caption TextBox and mnuLarge in the Name
TextBox.
 When FillColour menu item is selected, a submenu with Red, Green and Blue should pop-up. Hence, these
items should be included below the Fill Colour item.

Writing Code for Menu Controls


Each menu control has a click event, which is executed when the menu item is selected or clicked. The
following code is entered in the general declarations section of the Form colour.frm.
Option Explicit
The following code is entered in the Form_Load( ) procedure.
Private Sub Form_Load()
mnuGreen.Enabled = False
mnuSmall.Enabled = false
End Sub
Initially the window is small and the Form is green in colour. Hence the menu items Small and Green are
disabled. The following code is entered in the mnuRed_Click( ) procedure.
Private Sub mnuRed_Click()
frmColor.BackColor = QBColor(4)
mnuRed.Enabled = False
mnuGreen.Enaoled = True
mnuBlue.Enabled = True
End Sub
When the menu item Red is clicked, mnuRed procedure is executed this changes the colour of the Form to red
and disables the Red menu item. The procedure then enables the Green and Blue menu items because the colour
Form is now red and it should be changed to either blue or green.
Private Sub mnuBlue_Click()
frmColor.BackColor = QBColor(1)
mnuBlue.Enabled = False
mnuRed.Enabled = True
mnuGreen.Enabled = True
End Sub
When menu item Blue is clicked, the mnuBlue_Click( ) procedure is executed which changes the colour of the
Form to red and disables the Blue menu item. The procedure then Green and Red menu items because the
colour of the Form is now blue and it should be changed to either green or red.
Private sub mnuGreen_Click()
frmColor.BackColor = QBColor(2)
mnugreen.Enabled = False
mnured.Enabled = True
mnublue.Enabled = True
End Sub
When the menu item Green is clicked, the mnuGreen_Click( ) procedure is executed which changes the colour
of the Form to green and disables the Green menu item. The procedure then enables the Red and Blue menu
items because the colour of the Form is now green and it should be changed to either blue or red.
Private Sub mnuLarge_Click()
frmColor.WindowState = 2

Dept. of Computer Science, BCAS, Erode 35


Visual Programming – Unit II

Large.Enabled = False
mnusmall.Enabled = True
End Sub
When the menu item Large is selected, the mnuLarge_Chck.( ) procedure is executed which maximizes the size
of the Form and disables the Large menu item. The size of the Form is changed by setting the WindowState
property of the Form.
Private Sub mnuSmall_Click()
frmColor.WindowState = 0
mnuSmall.Enabled = False
mnuLarge.Enabled = True
End Sub
End statement is added in the mnExit_Click( ) To terminate the application. When the menu it Small selected,
mnuSmall_Click() procedure is executed which minimizes the size of the Form and disables the Small menu
item.

Adding a Separator Bar and Shortcut Keys


A separator bar is line which separates the menu items. It is mainly useful for obtaining clarity. The
Colours program can be enhanced by adding a separator bar between the FillColour and Exit menu items.
 Exit menu is selected in the menu Editor and Insert button is clicked.
 In the Caption TextBox ‘-‘ typed and mnuSep is typed in the Name TextBox. The OK button is clicked.
This adds a separator line, which is drawn between the FillColour and Exit menu items.

Popup Menu
A pop-up menu is a floating menu that is displayed over a Form independent of the menu bar. Pop-up
menus are also called context menu because the items displayed on the pop-up menu depend on where the
pointer is located when the right mouse button is clicked. Any menu can be displayed as a pop-up menu at run
time provided it has one menu item. The following code displays the Colours menu when the user clicks the
right mouse button over the Form at run time.
Private Sub Form_MouseDown(Button As Integer, Shift As
Integer, X As Single, Y s Single)
If Button = 2 Then
PopupMenu mnuCo1ors
End If
End Sub

Making Menu Controls invisible


In the above program, menu items are enabled and disabled at run time by setting the Enabled property
to True or False. When a menu item is disabled, it is dimmed and cannot be selected. But it is still visible and
the menu items are seen. Sometimes it is required to hide the menu items completely. We can do this using the
following statement.
MnuItem.Visible = False
The following code entered in the Form_Load( ) procedure of the Colours program makes the menu item Exit,
invisible at runtime.
mnuExit.Visible = False
The whole menu is made invisible by setting the visible property of the menu's title to False. The following
code entered in the Form_Load() procedure makes the Colours menu invisible.
mnuColors.Visible = False

Dept. of Computer Science, BCAS, Erode 36


Visual Programming – Unit II

Using Check Marks


Some programs may require check marks to be placed in the menu items. To place a check mark in a
menu item, the checked property is set to True. The following example code entered in the Form_Load( )
procedure places a check mark in the menu item Red.
mnuRed.Checked = True
The following code entered in the Form_Load( ) procedure unchecks the menu item Red.
mnuRed.Checked = False

Menu Control Arrays


A menu control array is a set of menu items on a menu that share the same name and event procedure.
Each menu control array element is identified by a unique index value, indicated in the Index property box on
the menu editor. When a member of a menu control array recognizes an event, VB passes the index property
value to the event procedure as an additional argument. The event procedure must include the code that can
check the value of the Index property.

3.2 Mouse Events


Visual Basic Applications respond to various mouse events, which are recognized by most of the
controls, the main events are MouseDown, MouseUp and MouseMove. MouseDown occurs when the user
presses any mouse button and MouseUp Occurs when the user releases any mouse button: MouseMove occurs
whenever the mouse pointer is moved to a new point on the screen. These events use the arguments button,
Shift, X, Y and they contain information about the Mouse's condition when the button is clicked.

The first argument is an integer called Button. The value of the argument indicates whether the left, right
or middle mouse button was clicked. The second argument is an integer called shift. The value of this argument
indicates whether the mouse clicked simultaneous with the Shift key, Ctrl key or Alt key. The third and fourth
arguments X and Y are the co-ordinates of the mouse location at the time mouse was clicked. As the Form is
executed automatically whenever the mouse button is clicked inside the Form’s area x, y Co-ordinates are
referenced to the Form.

Positioning a Control
Mouse Down is a commonly used event and it is combined with a Move method to move an
ImageControl to different location in a Form. The following application illustrates the movement of object
responding to events. It makes use of two OptionButton controls, two Image controls and a CommandButton.
The application is designed in such a way that when an OptionButton is selected, the corresponding image
control is placed anywhere in the Form whenever it is clicked.
Example
A new Standard Exe project is opened and the Form and the project files are saved as Move.frm and
Move.vbp. The form is designed as per the properties given below:
Object Property Setting
From Caption Mouse Down Application
Name Form1
OptionButton Caption Credit card is selected
Name Optionl
Value True
OptionButton Caption Cash is selected
Name Option2

Dept. of Computer Science, BCAS, Erode 37


Visual Programming – Unit II

Image Name imgcard


Picture c: \credit.hmp
Image Name imgcash
Picture c:\cash.hmp
The following code in entered in the general declaration section of the Form
Option Explicit
The following code is entered in the Form_MouseDown( ) event.
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X
As Single, Y As Single)
If Option1 = True then
imaCard.Move X, Y
Else
imgCash.Move X, Y
End If
End Sub
The application is run by keying in F5. When the mouse is clicked over the Form, the selected image moves to
that location where the mouse is clicked.

Graphical Mouse application


Mouse events can be combined with graphics methods and any number of customized drawing or
painting applications can be created. The following application combines MouseMove and MousaDown events,
and illustrates a drawing program.

Example
A new Standard EXE project is opened and the Form and project files are saved as Draw.frm and Draw.vbp.
The Name and Caption properties of the Form are changed to frmDraw and LINE DRAWING APPLICATION.

The following code is entered in the general declarations of the frmDraw Form,
Option Explicit
The following code is entered in the Form_MouseDown( ) procedure.
Private Sub Form_MouseDown(Button As Integer, Shift As Integer,
X As Single, Y As Single)
frmDraw.CurrentX = X
frmDraw.CurrentY = Y
End Sub
The following code is entered in the Form_MouseMove( ) procedure.
Private Sub Form_MouseMove(Button As Integer, Shift As Integer,
X As Single, Y As Single)
If Button = 1 Then

Dept. of Computer Science, BCAS, Erode 38


Visual Programming – Unit II

Line (frmDraw.CurrentX, frmDraw.CurrentY)-(X, Y)


End If
End Sub
Button va1ue 1 indicates that the left mouse button is clicked. The code written in the MouseDown event
changes the CurrentX and CurrentY to the co-ordinates where the mouse was clicked. The program is executed
by pressing F5. When the mouse button is clicked and moves in the Form a line is drawn corresponding to the
mouse movement. Below Figure shows the combined action of MouseDown and MouseMove.

This program uses two graphics related Visual Basic concepts: for the Line method and the currentX and
CurrentY properties. Line method is preferred for drawing a line in a Form. The following statement draws a
line from the co-ordinates x=2500, y=2000 to x=5000, y = 5500
Line(2500,2000)-(5000,5500)
The CurrentX and CurrentY properties are not visible in the Properties window of the Form because it
cannot be set at the design time. After using the Line method to draw a line in a Form, Visual Basic
automatically assigns the co-ordinates of the line's end point to the CurrentX and Current Y properties of the
Form on which the line was drawn.

Visual Basic does not generate a MouseMove event for every pixel the mouse moves over and a limited
number of mouse messages are generated per second by the operating environment. The following application
illustrates how often the Form_MouseMove( ) procedure is executed.

Example
A new Standard EXE project is opened and the Form and the Project files are saved as MouseMove.frm
and MouseMove.vbp.
Object Property Setting
From Caption Mouse Move Application
Name frmMouseMove
CommandButton Caption &Clear
Name cmdClear
Font System
The following code is entered in the general declaration of the Form.
Option Explicit
The following code is entered in the Form MouseMove event procedures
Private Sub Form_MouseMove()
circle(X, Y), 70
End Sub
The above simply draws small circles at the mouse’s current location using the Circle method. The parameters
x, y represent the centre of the circle and the second parameter represent the radius of the circle.
Private Sub cmdClear_Click()
frmMouseMove.Cls
End Sub

Dept. of Computer Science, BCAS, Erode 39


Visual Programming – Unit II

The program is executed by pressing F5. When the mouse inside the Form, circles are drawn along the path of
the mouse movement as shown in below figure. When the clear button is clicked it clears off the circles from
the screen. The circles are widely spaced when the mouse is moved quickly and viva versa. Each small circle is
an indication that the MouseMove event occurred and Form_MouseMove( ) procedure was executed.

Dragging and Dropping


Dragging is the process of clicking the mouse button in a control and moving the mouse while holding down the
mouse button. The action of releasing the mouse button after the dragging is called dropping. The following drag and drop
properties, events and method a supported in Visual Basic.
 DragMode property enables automatic or manual dragging of a control. Draglcon property specifies the icon that is
displayed when the control is dragged.
 DragDrop event is recognized when a control is dropped onto the object. DragOver event is recognized when a
control is dragged over the object.
 Drag method starts or stops manual dragging.
All controls except menus, timers, lines and shapes support the above mentioned properties and method. Forms
recognize the Drag Drop and Drag Over events but they do not support the Drag method and the Drag mode and DragIcon
properties.
Example
Develop an application that illustrates the drag and drop operation the following steps have to be undertaken
 A new Standard EXE project is opened and saved.
 An Image control is added and it DragMode is set to 1-Automatic. Picture property is set to c:\vb\...\
water.ico. Its Stretch property is set to True.
 A TextBox and a CommandButton is added to the Form.
 The following code is entered in the declaration section of the Form.
Option Explicit
 The following code is entered in Form_DragDrop( ) procedure.
Private Sub Form_DragDrop(Source As Control, X As Single,
Y As Single)
Text1.Text = ““
Source.Move X,Y
End Sub
 The following code is entered in Form_DragOver( ) procedure.
Private Sub Form_DragOver(Source As Control, X As Single,
Y As Single, State As Integer)
Dim Info As String
Info = “Now Dragging”
Info = Info + Source.Tag
Info = Info + "Over the Form"

Dept. of Computer Science, BCAS, Erode 40


Visual Programming – Unit II

Info = Info + “State=”


Info = Info + Str(State)
Textl.Text = Info
End Sub
 The following code is entered in Commandl_DragOver() procedure.
Private Sub Commandl_DragOver(Source As Control, X As Single,
Y As Single, State As Integer)
Dim Info As String
Info = "Now Dragging"
Info = Info + Source.Tag
Info = Info + "Over the Exit button”
Info = Info + "State=”
Info = Info + StrState)
Textl.Text = Info
End Sub
 The following code is entered in Commandl_Click( ) procedure.
Private Sub Commandl_Click()
End
End Sub
 The Form is executed by pressing F5. When the Image is dragged over the Form it sage in the TextBox.
Similarly, a message is displayed when it is moved over the Exit button.

3.3 Dialog Boxes


Dialog Boxes are used to display information and to prompt the user about the data needed to continue an
application. There are three ways of adding dialog boxes to an application, which are as follows
 Predefined Dialog Boxes – Created using InputBox( ) and MsgBox( ) function.
 Custom Dialog Boxes – Created by adding controls to the Form or by customizing an existing dialog box.
 Standard Dialog Boxes - Created using Common Dialog Control.

Modal and Modeless Dialog Boxes


Dialog Boxes are either Model or Modeless. A Modal dialog box does not allow the user to continue with other
applications unless it is closed or unloaded. The Modeless dialog box allows shifting of focus between the
dialog box and another Form without closing the dialog box. For displaying a Form as a model dialog box we
can use the show method with a style argument 1 as given below.
Form1.Show 1
For displaying the Form as a modeless dialog box we use the show method without a style argument.
Form1.Show

Dept. of Computer Science, BCAS, Erode 41


Visual Programming – Unit II

Predefined Dialog Boxes


Predefined dialog boxes can be added easily to an application. This uses the InputBox and MsgBox
functions. These dialog boxes are always model. Let us design a small program to get familiar with MsgBox( )
function.
Example
A new Standard Exe Project is opened and the Form and the project files are saved as Dialog.frm and
Dialog.vbp. The program is designed as per table given below:
Object Property Setting
From Caption DISPLAY FORM
Name Form1
Menu items are added to the Form as table given below. The designed application is represented is shown in the
below figure:
Caption Name
&File mnuFile
…D&isplay mnuDisplay
- mnuSep1
…E&xir mnuExit

The following code is entered in mnuDisplay_Click( ) procedure.


Private Sub mnuDisplay_Click()
Dim Message As String
Dim DialogType As Integer
Dim Title As String
Message = “Hava a gala shooping”
DialogType = vbOK + vbinformation
Title = “Welcome to Super Market”
MsgBox Message, DialogType, Title
End Sub
The mnuDisplay_Click procedure updates the three variables Message, DialogType and Title that are used as
parameters to the MsgBox statement before executing it. As a result a message box appears as shown in the
below figure. vbOK and vbExclamation are VB constants that represent the OK icon and Exclamation point
icon. The following code in entered in mnuExit_Click( ) event procedure
Private Sub mnuExit_Click()
Dim Message As String
Dim DialogType As Integer
Dim Title As String
Dim Response As Integer
Message = “Thank You, Shop again”
DialogType = vbOK + vbinformation

Dept. of Computer Science, BCAS, Erode 42


Visual Programming – Unit II

Title = “Good Bye”


Response = MsgBox Message, DialogType, Title
If Response = vbYes Then
End
End If
End Sub
The mnuExit_Click( ) procedure updates the variables Message, DialogType and Title. Once these three
variables are updated, Msg Box( ) function is executed and its return value is assigned to the variable
Response. The returned value of the MsgBox( ) function indicates the button that was clicked.

The MsgBox( ) function takes the same parameters as the MsgBox statement. The only difference between the
MsgBox statement and MsgBox( ) function is that the function returns a value. The returned value indicates the
button that was clicked in the dialog box.

This application is run by pressing F5. A form appears as shown in below figure. By clicking the Display item,
a dialog box with exclamation point icon and OK button appears. By clicking the Exit menu, a dialog box with
a message appears as shown in above figure. If Yes is clicked, the application terminates.

Using InputBox Function


The InputBox( ) Function displays a model dialog box that asks the user to enter some data. The dialog
box contains a message, an OK button and a Cancel button. The user can type in the TextBox and close the
Dialog box by clicking OK. The first parameter of the InputBox( ) function is the message of the dialog box and
second parameter is the title of the message box.
I = InputBox(“Enter a Date: “, “Date Demo”)
Let enhance the Dialogs program in order to understand the usage of InputBox( ) function. New menu
items are inserted before Exit menu item of the Dialog program. It should have the following characteristics.
Caption Name
…Get &Date mnuDate
…Get &Value mnuValue
- mnuSep2
The following code is entered in the event procedure mnuDate_Click().
Private Sub mnuDate_Click()
Dim I, Day, Msg
I = InputBox(“Enter a Date: “, “Date Demo”

Dept. of Computer Science, BCAS, Erode 43


Visual Programming – Unit II

If Not IsDate(1) Then


MsgBox “Invalid Date”
Exit Sub
End If
Day = Format(I, “dddd”)
Msg = “Day of this date is: “ +Day
MsgBox Msg
End Sub
Whenever Get Date menu is clicked the code in the mnuDate Procedure asks the user to enter a date and verifies
if the date is valid. An InputBox with a message Enter a Date and Ok and Cancel buttons as shown in below:

When date is typed in the TextBox, the procedure determines whether it is valid date or not. If variable I is
filled with characters such as ABC or 1234 the condition. Not IsDate() is satisfied and it displayed a message
box with the message “Invalid Date”.

If the value entered is valid one such as 12/04/18, the condition Not IsDate(1) is not satisfied and the
user is prompted with a message box indicating the day of that date as shown in the below figure:

The following code is entered in the event procedure mnuValue_Click().


Private Sub mnuValue_Click()
Dim I As Integer
I = InputBox(“Enter a Value: “, “Input Demo”)
End Sub
When the menu Get Value item is clicked, it is displays an InputBox prompting the user to enter a value. This
procedure allows the user to enter only integer values in the TextBox. If the user enters a value other than an
integer it displays an error value.

Custom Dialog Control


A custom Dialog box is a Form that is created containing controls including CommandButton,
OptionButton and TextBox controls that supply information to the application. Custom dialog boxes are
customized by the user. The appearance of the Form is customized by setting the property values. Let us the
Dialogs in order to understand the methodology for designing a custom dialog and its use in a program.
Example
 The Dialog.vbp project is opened and a new Form is added to the project by selecting the Add Form from
the Project menu. The Form of the project is saved as Custom.frm.

Dept. of Computer Science, BCAS, Erode 44


Visual Programming – Unit II

 The Custom.frm is designed as per Table given below


Object Property Setting
From Caption DISPLAY FORM
Name Form2
MaxButton False
MinButton False
ControlBox False
Border Style 1-Fixed Single
OptionButton Caption Monday
Name Option1
OptionButton Caption Tuesday
Name Option2
OptionButton Caption Wednesday
Name Option3
OptionButton Caption Thursday
Name Option4
OptionButton Caption Friday
Name Option5
OptionButton Caption Saturday
Name Option6
OptionButton Caption Sunday
Name Option7
CommandButton Caption &OK
Name Command1
CommandButton Caption E&xit
Name Command2
The BorderStyle property of the Form2 dialog box is set to 1-fixed single and hence the size of the dialog box is
not changed during run time. The dialog box is displayed without a Control Menu at runtime because the
ControlBox property is set to False. The dialog box is displayed without using Minimize and Maximum button
since the Min Button and Max Button property of the Form2 is set to true.

 Two menu items are added to the Form1 of the Dialog.vbp project with the following characteristics. These
menu items are inserted above the Exit menu item.
Caption Name
…Get a Da&y mnuDay
- mnuSep3
The following code is entered in the mnuDay_Click( ) procedure of Form1
Private Sub mnuDay_Click()
Form2.Show 1
If Form2.Tag = “ “ Then
MsgBox “Dialog Box is Cancelled”
Else
MsgBox “The Selected Day is: ” + Form2.Tag
End If
End Sub

Dept. of Computer Science, BCAS, Erode 45


Visual Programming – Unit II

When the menu item Get a Day is clicked, it displays the Custom.frm as a custom dialog box and prompts the
user to select a day. It also displays the day which is selected by using the Tag property of the Form2 dialog
box. The code uses Form2.Tag to store the name of the day which is selected.

The following code is entered in Command1_Click( ) procedure of Form2.


Private Sub Command1_Click()
If Option1 = True Then Form2.Tag = “Monday”
If Option2 = True Then Form2.Tag = “Tuesday”
If Option3 = True Then Form2.Tag = “Wednesday”
If Option4 = True Then Form2.Tag = “Thursday”
If Option5 = True Then Form2.Tag = “Friday”
If Option6 = True Then Form2.Tag = “Saturday”
If Option7 = True Then Form2.Tag = “Sunday, No Transaction”
Form2.Hide
End Sub
Whenever the OK button of the Form2 dialog box is clicked, the code written in the procedure of
Command1_Click() procedure is executed. The If statement are used here to ascertain the option button that is
currently selected and accordingly updates the Tag property of the Form2 dialog box with the name of the
selected day. After the If statement, the procedure uses the Hide method to hide the Form2 dialog box. The Tag
property of the dialog box is used as the output of the dialog box. When the user selects the option Sunday, a
message box is displayed as shown below.

The following code is entered in the Command2_Click() procedure of Form2 dialog box.
Private Sub Command2_Click()
Form2.Tag = “ “
Form2.Hide
End
End Sub
Whenever the Exit button is clicked, the Tag property of the Form2 dialog box is set to null and the Hide
method hides the Form. Setting Form2.Tag to null indicates that the user has clicked the Exit menu.

Using the Common Dialog Control


The Common Dialog Control is a custom control that displays the commonly used dialog boxes such as
Save As, Colour, Font, Print and File Open. When a common dialog control is drawn on a Form1 automatically
resizes itself and it is invisible at run time. The common dialog box is used as a dialog box that lets the user
select and save files.

Dept. of Computer Science, BCAS, Erode 46


Visual Programming – Unit II

 Components is selected from the Project menu which displays a Components box.
 After ensuring that Common Dialog 6.0 Control CheckBox has a check mark in it, the OK is clicked
Example
 A new Standard EXE is opened and the Form and the project are saved as cmdialog.frm and Cmdialog.vbp.
 The application is designed and menu items are added to the to the From as per below Tables specifications
 The designed Form is represented in below Figure
Object Property Setting
From Caption The Common Dialog Program
Name Form1
CommonDialog Cancel Error True
Name CommonDialog1

Caption Name
&File mnuFile
…Color mnuColour
…Open mnuOpen
- mnuSep
...E&xit mnuExit

The following code is entered in the mnuColour_Click( ) procedure.


Private Sub mnuColor_Click( )
On Error GoTo errortrap
COmmonDialog1.Action = 3
Forml.BackColor = CommonDialog1.Color
Exit Sub
errortrap:
MsgBox "Dialog Box is cancelled."
End Sub
Whenever Colour menu is selected it displays a Colour dialog box as shown in below Figure.

Before displaying the dialog box, the mnuColour_Click( ) procedure sets an errortrap. The purpose of an
errortrap is to detect an error during the display of the dialog box. We have set the CancelError Property of the
Dept. of Computer Science, BCAS, Erode 47
Visual Programming – Unit II

CommonDialog1 control to true at design time. Therefore, if Cancel button is pressed when the dialog box is
displayed, the errortrap, which has been set displays the “Dialog Box is Cancelled” and dialog box disappears.
However, if specific colour is selected from the dialog box and OK button is clicked the Back Colour of the
Form is changed to that particular colour. The following code is entered in the mnuOpen_Click( ) procedure.
Private Sub mnuOpen_Click()
Dim filter As String
On Error GoTo errortrap
fi1ter = “all files(*.*) | *.*”
CommonDialogl.filter = fi1ter
CommonDialogl.Action = 1
MsgBox "Selected file is: “+CommonDialog1.filename
Exit Sub
errortrap:
MsgBox “Dialog box is cancelled”
Exit Sub
End Sub
The above procedure displays an Open dialog box. Before displaying the dialog box, the first statement of the
mnuOpen_Click() procedure sets an errortrap which detects an error during the display of the dialog box. If
the Cancel button is pressed when the dialog box is displayed, the errortrap, which has been set, displays the
message “Dialog Box is cancelled” and the dialog box disappears. However, If a specific file is selected from
the dialog box the name of the selected file is displayed as a message box. The filter property of the
CommonDialog1 is set to the value of the filter variable Action property to 1, displays the Open dialog box
Private Sub mnuExit_CliCK )
End
End Sub
The above procedure terminates the application. Like Colour and Open dialog boxes, the properties of the
Common Dialog Control may used to determine the user’s response to the dialog box. Action property 4
displays the Font dialog box and 5 displays the Print dialog box.

RichTextBox Control
The RichTextBox control allows the user to enter and edit text while also providing more advanced
formatting feature than the conventional 'I'extBox control. It almost works like an editor. The RichTextBox
control provides a number of properties we can use to format any portion of text within control. Using these
properties, we can make the text bold or italic, change it colour, and create superscripts and subscripts. We can
also a paragraph formatting by setting both left and right indents, as well as hanging indents.

******

Dept. of Computer Science, BCAS, Erode 48


Visual Programming – Unit II

4. Graphics, MDI and FlexGrid


4.1 Graphics For Application
Visual Basic provides a number of ways of creating and using graphics in an application, which adds
styles, interest and visual structure to the interface of an application. Graphic objects such as lines, circles and
bitmaps can be displayed in Visual Basic in a quicker and easier way. This section concentrates on two
approaches for creating graphics for an application using
 Graphical controls
 Graphics methods

Fundamentals of Graphics
Various controls and methods are used in Visual Basic to draw points, lines, boxes, circles and other
shapes and their location and appearance on a Form can be changed. There are some basic idea that is used for
creating graphics using twips, coordinate system and simple colour.

A twip is a unit that specific the dimensions and location of the object. The number of times a twip is
used by all Visual Basic movement. There are 1440 twips in one inch. These measurements designate the
object’s size then printed. The co-ordinate system is a two-dimensional grid that define location either on the
Form or any other container which or an any other container which is represented as (X, Y). A colour is
represented by a long integer and there are four ways of specifying it at run time; RGB function, using
QBColour function using one of the intrinsic constants in the Object Browser or by entering a colour value
directly.

The RGB( ) function enables the user to specify colours. The RGB( ) function has three arguments. The
value of the first argument represent amount of Red in the final colour the second argument represents Green
and the third represents Blue. The maximum value of each argument is 255 and minimum is 0. The following
statement uses the RGB function to give the colour red.
RGB (255, 0, 0)
The following statement returns yellow colour.
RGB (255, 255, 0)
QBColour function takes a single number that specifies a Quick Base colour number from 0 to 15 and returns a
long integer that can be used in the Visual Basic Colour property.
Forml.BackColor = QBColor (8)
This changes the background colour of the Form to grey.

Using Graphical Controls


Visual Basic provides three controls for creating graphical applications such as Line, Image and Shape.
These controls are very useful while design. The main advantage of graphics control is that user can create an
application with less code. Fewer system resources are sufficient than other VB controls.

Line Control
A Line control is a straight line segment that is drawn at design time. The position, length, color and
style of the Line control can be positioned to customize the look of the application.

Shape Control
A Shape control is a visual element that contains several predefined specified shape. In order to view a
specific shape, control is added to the Form by double clicking it. The default shape is rectangle. The Shape

Dept. of Computer Science, BCAS, Erode 49


Visual Programming – Unit II

property is selected from the Properties window, which drops a list of shapes, from which a user can select the
desired one.

The FillColor and FillStyle properties of the Shape control can be changed so that the desired color and
style can be obtained.

Image Control
An Image control is a rectangular portion into which picture files can be loaded. Picture files include
bitmap files, icon files and metafiles. A bitmap also called "paint type" graphics defines an image as a pattern of
dots. It has a filename with extension .bmp. An icon is a special kind of bitmap with extension .ico.

Adding Pictures
Line control and Shape control are used for drawing geometric shapes such as lines, circle, squares,
and so on. For drawing more complex figures user can use a picture file. A picture file can be loaded on a
Form, Image control or Picture control. A picture can be added using the following two ways at design time.
 In the Properties window of the Form, the Picture property is selected. Visual Basic displays a dialog box
from which a picture file can be selected. The selected picture is displayed in the Form as its background.
Similarly a picture can be loaded in PictureBox and Image control.
 A picture can be copied from another application such as Paintbrush to the Clipboard and by selecting Paste
command from the Edit menu, the picture can be pasted onto a Form, Picture Box or Image Control.

A picture can be added using the following ways at run time.


 LoadPicture function is used to specify the filename and assign the picture to the Picture property.
 Any picture loaded to a Form, PictureBox or Image control can be copied to another Form, PictureBox or
Image control. The following statement copies a picture from Image control to a PictureBox.
Set Picturel.Picture = Imagel.Picture
 A picture can be copied from a Clipboard object.

Removing Pictures
A picture can be removed at run time using the LoadPicture function without arguments. The following
statement removes a picture from an image control at run time.
Set Image1.Picture = LoadPicture(““)

Moving and Sizing Pictures


In a Form, PictureBox or an Image control is moved, the picture associated with it also moves
automatically. The AutoSize property of a picture box can be set to True in order to automatically expand and
accommodate a new picture at run time. The AutoSize property can also be used to shrink a control in order to
reflect the size of a picture. This property is not available in the Form and Image control but they automatically
size themselves to fit the picture loaded onto them.
Dept. of Computer Science, BCAS, Erode 50
Visual Programming – Unit II

Stretch Property of an Image control is used to automatically resize a picture and place it inside the
control. When this property is set to True, the image control resizes the picture the desired size to fit into the
control. When this property is set to False, the control automatically adjusts its size to the size of the picture
loaded on to it.

Using Graphics Methods


The graphics method operates on controls such as Form, Picture Box or Printer forms run time drawing
operations such as animation or simulation. Visual Basic offers several methods such as Cls, PSet, Point to
create graphics applications. The graphics method offers some visual effects that are not available in the
graphics controls. For example individual pixels can be painted only by using graphics method. PSet’s method
sets the colour of an individual pixel. Every graphics method draws output on a Form, PictureBox or to the
Printer following statement draws a point on a Form named Form1.
Forml.PSet(500, 500)
The PSet method draws a point at x, y co-ordinates that are specified by its arguments. Cls method clears all the
graphics. The following statement clears the Form Form1.
Forml.Cls
The Point method returns the colour of a particular pixel. For example the following Statement is used to find
the colour of the pixel at location 30, 40.
PixelColor = Point(30, 40)
The Line method draws a line, rectangle or filled-in text box. The Line method has the following syntax.
Line(xl, yl)-(x2, y2), Color
where (xl, yl) is the co-ordinate of the starting point and (x2, y2) is the co-ordinate of the ending point of the
line. If the co-ordinates xl, yl are omitted, the line is drawn starting at the co-ordinate CurrentX, CurrentY. The
following statement draws a slanted line on the Form.
Line(600,600) - (2000,2000)
An optional step argument can be used with the Line method as follows.
Line(xl, yl) – Step(dX, dY), Color
where (xl, yl) are the co-ordinates of the starting point and Step(dX, dY) is an indication that the end point of
the line is at xl+dX, yl+dY. The following statement draws a line with the starting point co-ordinates 30, 40 and
ending point co-ordinate 80, 140.
Line(30,40)- Step(50,100)
The Line method is used to draw and fill boxes. The following example draws a box with its upper left corner at
(600, 600) and measuring 1000 twips on each side.
Line(600, 600) - Step(1000, 0)
Line - Step(0, 1000)
Line - Step(-1000, 0)
Line - Step(0, -1000)
Visual Basic provides a much simpler way to draw a box, which replaces the above four statements into a single
statement as given below.
Line(600, 600) - Step(1000, 1000), , B
B option is used with the Line method. This causes a box to be drawn using the coor0dantes to specify opposite
corners of the box. It is to be noted that two commas are required before B to indicate that the colour argument
has been skipped.

Dept. of Computer Science, BCAS, Erode 51


Visual Programming – Unit II

A circle method is used to draw a variety of circular and elliptical shapes. To draw a circle, Visual Basic
requires the location of the circle's centre and the length of its radius. The following statement draws a circle
with a center(1400, 1200) and radius 650.
Circle(l400,1200), 650

4.2 Multiple Document Interface (MDI)


MDI stands for Multiple Document Interface. A Multiple Document Interface is used for opening many
windows at the same time. All the document windows are contained in a parent window, which provides a
workspace in the application. Visual Basic applications can have only one MDI Form, which contains all the
Child Forms. A Child Form is an ordinary Form that has its Child property set to True. Child Forms are
displayed within the internal area of an MDI Form at run time.

Creating an MDI Application


The Multiple Document Interface can be designed for document-centred applications. This application
allows the user to open many similar documents at the same time. To create a document-centred application in
Visual Basic, we require atleast two Forms, an MDI Form and a Child Form. This application is designed
similar to the Notepad application in Microsoft Windows. Each time the user clicks New from the File menu, a
new Child window is created and displayed.
Example
 A new Standard EXE project is opened. An MDI Form is inserted by selecting Add MDI Form from the
Project menu. The Project now contains a standard Form and an MDI Form. The project is saved as
mdi.vbp. The Form is saved as Child.frm and the MDI Form as Parent.frm,
 A TextBox is added in the standard Form. The two Forms are designed as per below specifications.
Object Property Setting
MDIFrom1 Caption Parent Form
Form1 Caption Child Form
MDIChild True
Text1 MultiLine True
Text (Empty)
Left 0
Top 0
Height 2295
Width 3015
ScrollBars 3-Both
Menu items are added to the MDI Form as per the specifications shown in above Table. The designed Forms
1ooks like resemble the one shown in the below Figure
Caption Name
&File mnuFile
…&New mnuNew
…E&xit mnuExit
&Window mnuWindow
...&Cascade mnuCascade
...&Tile mnuTile

Dept. of Computer Science, BCAS, Erode 52


Visual Programming – Unit II

The following code is entered in the mnuNew_Click() procedure of the MDIForm1.


Private Sub mnuNew_Click()
Dim NewForm As New Forml
NewForm.Show
End Sub

The first statement in the above procedure declares a variable called NewForm as a copy of the Child Form
Form1. This implies that, for all purposes, the NewForm can be referred to as an instance of the Form1 with the
same properties that Form1 had at the time of design. The second statement in the procedure causes the newly
created Form to pop up. Every time when the menu item New is clicked in the MDI form, a new Form pops up.
The following code is entered in the mnuTile_Click( ) procedure of the MDI form.
Private Sub mnuTile_Click()
MDIForm1.Arrange vbTi1eHorizonta1
End Sub
The code in the mnuTile_Click() procedure uses the Arrange method with vbTileHorizontal as the argument
to Tile the Child Forms. Below Figure represents the Forms in Tile arrangement. This procedure is executed
when the menu item Tile is clicked. The following code is entered in the mnuCascade_Click( ) procedure of the
MDI form.

Private Sub mnuTile_Click()


MDIForm1.Arrange vbCascade
End Sub

Dept. of Computer Science, BCAS, Erode 53


Visual Programming – Unit II

The code in the mnuCascade_Click( ) procedure uses the Arrange method with vbCascade as the argument to
cascade the Child Forms. Below Figure represents the cascaded forms. The following code is entered in the
mnuExit_Click( ) procedure.
Private Sub mnuTile_Click()
End
End Sub
When the menu Exit is clicked, the application terminates.

Adjusting the TextBox


The Text Box in the Child Form can be adjusted to the same size of the Child Form Form1. This can be
incorporated in to the Resize event. The Resize event is fired whenever the size of the Form is changed.
Therefore, the Form_Resize( ) procedure is a focal point that is executed whenever the Form size of the Form
changes. The following code is entered in the Form_Resize( ) procedure of the Form1 Child Form.
Private Sub Form_Resize()
Me.Textl.Height = Me.ScaleHeight
Me.Textl.Width = Me.ScaleWidth
End Sub
The first statement of the above procedure assigns the ScaleHeight property of the current Form to the Height
property of the TextBox and the second statement assigns the ScaleWidth of the Form to the width of the
TextBox. Hence the TextBox has the size of the current Form as represented in below Figure.

The Me reserved word used in the Form_Rcsizc( ) procedure is a variable containing the name of the
Form where the code is currently executed. The Me keyword in Visual Basic behaves like an implicitly declared
variable. For example, in the above program, there may be several instance of the child form in the parent form.
When the size of one of these forms is changed, the Form_Resize( ) procedure is executed and automatically
updates the Me variable with the instance that was resized.

Creating a Toolbar
Most of the Windows programs include a Toolbar, which is an area containing control to provide quick
access to the most commonly used operations. Toolbar is also called a ribbon bar or control bar. In order to add
a Toolbar item, the MDI form is selected and the Picture control in the Toolbox is double clicked. Visual Basic
responds by displaying a PictureBox control in the Form as shown in below Figure.

Dept. of Computer Science, BCAS, Erode 54


Visual Programming – Unit II

Displaying a Status Bar


Status bars are similar to the toolbars except that the status bar appears at the bottom of an MDI
form. The Picturelsox can be displayed at the bottom of the Form by setting the 1 1s property to 2-Align
Bottom. A status bar may display information about the currently selected object or the state of an application.

4.3 Using the FlexGrid Control


An MSFlexGrid control in Visual Basic is used to create applications that present information in row
and column. It displays information in cells. A cell is a location in the MSFlexGrid at which a row and a
column intersect. The user can select a cell at run time by clicking it or by using the arrow keys, but cannot edit
or alter the cell’s contents. The MSFlexGrid control displays and operates on tabular data. It allows complete
flexibility to sort, merge, and format tables containing strings and pictures. When bound to a Data control,
MSFlexGrid displays read-only data.

User can place text, or a picture, or both in any cell of an MSFlexGrid. The Row and Col properties
specify the current cell in an MSFlexGrid. We can specify the current cell in code, or the user can change it at
run time using the mouse or the arrow keys. The Text property references the contents of the current cell. If a
cell's text is too long to be displayed in the cell, and the WordWrap property is set to True, the text wraps to the
next line within the same cell. To display the wrapped text, we need to increase the cell's column width
(ColWidth property) or row height (RowHeight property). The Cols and Rows properties are used to determine
the number of columns and row in an MSFlexGrid control.

Two kinds of rows or columns are created in the MSFlexGrid control. They are fixed and non-fixed. A
non-fixed row or column scrolls when the scroll bars are active in the MSFlexGrid control. A fixed row or
column does not scroll at any time. FixedRows or FixedCols is generally used for displaying headings. Rows
and columns are created by setting the four properties of the MSFlexGrid control such as Rows, Cols,
FixedRows and FixedCols. Since the MSFlexGrid control is an OCX control, user must make sure whether the
control is included in the project. If the control does not appear in the ToolBox, it is added by selecting
Components from Project menu and placing a check mark in the Microsoft MSFlcxGrid Control. This places
the control in the ToolBox.

Example
This example uses a MSFlexGrid to view the sales of a particular item in a particular month.
 Start a new Standard Exe project from the New project dialog box.
 The Form is designed as shown below.

 To add the FlexGrid, choose Components from the Project menu and check on the Microsoft Flexgrid
Control 6.0.
 The two combo boxes are named itemname and mnthname respectively.
 The MSFlexgrid is named as itmdet.
 The command button with caption Add shown in the above Figure is named as Add.
Dept. of Computer Science, BCAS, Erode 55
Visual Programming – Unit II

 In the general declarations section of the Form, the following code is entered to initialize two arrays.
Dim arrl(12) As String
Dim itm(6) As String
Dim i As Integer
 The following code is entered in the Form Load event:
itm(0) = “Stationeries”
itm(1) = “Groceries”
itm(2) = “Milk Products”
itm(3) = “Confectionaries”
itm(4) = “House hold item”
itm(5) = “Toys”
arrl (0) = "Jan"
arrl (1) = "Feb"
arrl (2) = "Mar"
arrl (3) = "Apr"
arrl (4) = "May"
arrl (5) = "Jun"
arrl (6) = "Jul"
arrl (7) = "Aug"
arrl (8) = "Sep"
arrl(9) = "Oct"
arrl(10) = "Nov"
arrl(l1) = "Dec"
itmdet.Row = 0
For i = 0 To 11
itmdet.Col = i + 1
itmdet.Text = arrl(i)
mnthname.Addltem arrl(i)
Next
itmdet.Co1 = 0
For i = 0 To 5
itmdet.Row = i + 1
itmdet.Text = itm(i)
itemname.Addltem itm(i)
Next
The two arrays are initialized itm, arrl are initialized in the Form Load. The first "For loop" shown above adds
the names of the month in the 0th row. The second "For loop" adds the names of the items in the 0th column.
 The following code is entered in the Add Button’s click event:
itmdet.Row = itemname.Listlndex + 1
itmdet.Col = mnthname.Listlndex + 1
itmdet.Text = Str(Val(itmdet.Text) + Val(sale.Text))

This event procedure stores the value of the sale of the item for the month specified.
Example
 A new Standard EXE project is opened and the Form of the project is saved as MSFlexGrid.frm
and the project file is saved as MSFlexGrid.vbp.

Dept. of Computer Science, BCAS, Erode 56


Visual Programming – Unit II

 MSFlexGrid control is placed in the Form by double clicking it. After placing it, the Rows property of the
MSFlexGrid is set to 7 and Cols property to 4.16.
 The Caption property of the Form is changed to MSFLEXGRIDAPPLICATION.
 After setting the properties, the MSFlexGrid control is enlarged vertically and horizontally by dragging its
handles.
 Now, the Form is designed as per the specification given above looks like the one shown in below Figure. A
menu title File is placed with a menu item Clear in the Form.

The following code is entered in the general declarations section of the Form.
Option Explicit
The following code is entered in the Form_Load( ) procedure of the Form1
Private Sub Form_Load()
FlexGridll.Row = 0
FlexGridll.Col = 1
FlexGridll.Text = "OF"
FlexGridll.Col = 2
FlexGridl.Text = "IMPACT"
FlexGridl.Col = 3
FlexGridl.Text = "IMP_NET"
FlexGridl.Col = 0
FlexGridl.Row = 1
FlexGridl.Text = "Jan-Feb"
FlexGridl.Row = 2
FlexGridl.Text = "Mar-Apr"
FlexGridl.Row = 3
FlexGridl.Text = "May-Jun"
FlexGridl.Row = 4
FlexGridl.Text = "Jul-Aug"
FlexGridl.Row = 5
FlexGridl.Text = "Sep-Oct"
FlexGridl.Row = 6
FlexGridl.Text = "Nov-Dec"
End Sub
The application is run by pressing F5. The program displays a FlexGrid control with seven rows and four
columns displaying the text in the top heading row and the left heading column. The FlexGrid control displays
information in a tabular format. Each cell can be viewed by using the arrow keys but values cannot be entered
directly into cells. The FlexGrid control has both the properties Row and Rows. Similarly it has properties Col
and Cols. Rows and Col properties can be set both during the design time and run tune whereas, the Row and
Col properties are set into action only during run time.

Changing the Cell Width and Cell Height


The height and width of the cells in the FlexGrid control can be widened in order to get a clear picture at
run time. A procedure is added to the Form by selecting the Add Procedure command from the Project menu
in the Code Window. The new procedure is named as SetColWidth. The following code is entered in the
SetColWidth( ) procedure.
Public Sub SetColWidth()
Dim counter

Dept. of Computer Science, BCAS, Erode 57


Visual Programming – Unit II

For counter = 0 to 3 Step 1


FlexGrid1.ColWidth(counter) = 1000
Next
End Sub
The code in this procedure uses a "For loop" to change the ColWidth property of each of the column to 1000
twips. The ColWidth property determines the width of the column. FlexGridl.ColWidth(0) determine the width
of column 0, and FlexGrid1.ColWidth(1) determine the width of column 1 and so on. This statement
SetCoJWidth is added to the end of the Form_Load ( ) procedure along with the code written previously.

Another procedure called SetRowHeight( ) is added by selecting from the Project menu and it is added
to the code. The following code is entered in the SetRowHeight( ) procedure.
Public Sub SetRowHeight()
Dim counter
For counter = 0 To 6 Step 1
FlexGridl.RowHeight(counter) = 350
Next
End Sub
The code in this procedure uses a "For loop" to change the height of each of the rows to 350 twips. The
RowHeight property determines the height of the cell. The SetRowHeight statement is added to the end of the
Form_Load( ) procedure as shown below.
Private Sub Form_Load()
..................................
.....Same Code written as before.....
SetRowHeight
SetColWidth
End Sub

Entering Values in the Column


The rest of the cells are filled with values by calling a procedure FillValues in the Form_Load( )
procedure. A new procedure called FillValues is inserted in the general declaration section of the Form. The
following code is entered in the procedure FillValues( )
Public sub FillValue()
Dim colcounter, rowcounter
For colcounter = 1 To 3 Step 1
FlexGrid1.Col = colcounter
For rowcounter = 1 To 6 Step 1
FlexGrid1.Row = rowcounter
FlexGrid1.Text = "NIL"
Next
Next
End Sub
To fill a specific cell with data, the following statements are added to the end of FillValues( ) procedure.
Public Sub FillValues( )
...........
...........
FlexGridl.Row = 1
FlexGridl.Col = 1

Dept. of Computer Science, BCAS, Erode 58


Visual Programming – Unit II

F1exGrid1.Text = "120"
F1exGridl.Row = 2
FlexGridl.Col = 1
FlexGrid1. Text = "150"
F1exGridl.Row = 3
FlexGrid1.Col = 2
FlexGrid1.Text = “180"
FlexGrid1.Row = 4
FlexGrid1.Co1 = 2
F1exGrid1.Text = "210"
FlexGrid1.Row = 5
FlexGrid1.Co1 = 3
FlexGrid1.Text = "240"
F1exGrid1.Row = 6
FlexGrid1.Col = 3
FlexGridl.Text = "270"
End Sub
The code which is added in the FillValues( ) procedure fills six cells in the FlexGrid by selecting the
Row and Col properties with the required row number and column number, and then sets the Text property of
the cell with the desired text. Below Figure represent a FlexGrid control with values filled in the specified cells.

Scroll Bars of the FlexGrid Control


Visual Basic automatically adds horizontal and vertical scroll bars in the FlexGrid control when the cells
do not fit into it. This is because the default values of the ScrollBar property of the FlexGrid control is set to 3-
Both. If we do not want the scroll bars to appear, the ScrollBars property is set to 0-None at design time or the
following code is added in the Form_Load( ) procedure.
FlexGrid1.ScrollBars = 0
Similarly, a FlexGrid control can be displayed with a single vertical scroll bar or horizontal scroll bar at run
time by setting the ScrollBars property at design time.

A FlexGrid control includes a property called FlexGridLines, which can be set to either True or False. The
default setting is True, which causes the control to appear with visible grid lines. If this property is set to False,
the control is shown without grid lines.
*******

Dept. of Computer Science, BCAS, Erode 59

You might also like