|
The Form design, mainform.vb
Rename
the Form Form1.vb created and add new controls to it
Classes used in this Form:
Timer, ImageList, ToolBar, Label, Panel, PictureBox, Button,
MainMenu
1-
Rename the Form
- On the View
menu , click Solution
Explorer
- In Solution
Explorer, expand the work_VBNet
project node and select
Form1.vb
- In
Properties windows, Type the new
File Name
|
Old |
New |
Filename : |
Form1.vb |
mainform.vb | | |
2- Picture files used by this form ...
- The folder
c:\work_VBNet_10\work_VBNet_10\pic stored the
bmp files
z_calculator.bmp,
z_booknot.bmp,
z_agenda.bmp,
z_intro.bmp, z_about.bmp
calculator_2.bmp, address book_2,
agenda_1. bmp, intro_icon_2.bmp,
about_icon_2
|
3- Modify the Form Properties
...
- On the View
menu , click Solution
Explorer
- In Solution
Explorer, expand the work_VBNet
project node
- Right click the
mainform.vb and click
View Designer on the shortcut
menu to open the Properties
Windows.
- In
Properties windows, modify
...
|
Old |
New |
Name: FormBorderStyle Icon: Menu: Size: Text: Window
State: |
Form1 Sizable Icon (none) 300,300 Form1 Normal |
mainform FixedSingle Icon mainMenu1
940, 758 work VB
2010,
main Maximized | | | |
- On the Project
menu , click work_VBNet Properties ...,
the work_VBNet Property Pages dialog box
appears
- In the Startup
object combo box, choose and select
mainform
- Click OK
|
1- |
The mainform.vb
design |
|
 |
2- |
From the Toolbox/Windows Form add these
controls ...
5 PictureBox
controls, 3 Label controls, 2
Panel controls, 1 Timer control, 1 ImageList
control, 1 Button
control, 1 ToolBar control, 1
MainMenu control |
|
- Add
5 PictureBox
controls
- PictureBox1,
PictureBox
Properties
Name:
Image:
Size
Mode: |
PictureBox1
System.Drawing.Bitmap
Autosize | |
Bitmap
file added =
C:\work_VBNet_10\work_VBNet_10\pic\
z_calculator.bmp
- PictureBox2
- Bitmap file
added =
C:\work_VBNet_10\work_VBNet_10\pic\
z_booknot.bmp
- PictureBox3
- Bitmap file
added =
C:\work_VBNet_10\work_VBNet_10\pic\
z_agenda.bmp
- PictureBox 4
- Bitmap file
added =
C:\work_VBNet_10\work_VBNet_10\pic\z_intro.bmp
- PictureBox 5
- Bitmap file
added =
C:\work_VBNet_10\work_VBNet_10\pic\z_about.bmp
|
- Add
the 3 Label
control
- Lrbt, Label
Properties:
Font:
Name:
Size:
Text:
TextAlign: |
Times New Roman, 14pt,
style=Bold,
Italic
Lrbt 152,
22
work2010 system
MiddleCenter | |
- ltimer
- Text:
timer
- lblb
-
Text:
""
|
- Add
2 Panel
controls
- Panel1,
Panel
Properties
Name:
Size: |
Panel1
156,
632 | |
- Panel11
-
Size: 156,
576
|
- Add
the ImageList control
- ImageList,
ImageListProperties:
Name:
Images:
ImageSize: |
ImageList1
(Collection)
- of 5
Bitmap images
56,
36 | |
The
folder
c:\work_VBNet_10\work_VBNet_10\pic stored the 5 bmp files
calculator_2.bmp, address
book_2, agenda_1. bmp,
intro_icon_2.bmp, about_icon_2.bmp
- Add
the Button control
- Btntools , Button
Properties:
Name:
BackColor:
Size:
Text: |
Btntools
DarkGray
150,
20
tools | |
- Add
the Timer
control
- Timer1,
Timer Properties:
Name: Enabled: Interval: |
Timer1 True 100 | |
- Add the ToolBar
control,
ToolBar1
ToolBar
controls are
used to display ToolBarButton controls
that can appear as a
standard button, a toggle-style button, or a
drop-down style button. You can assign
images to the buttons by
creating an ImageList, assigning it to the
ImageList property of the
ToolBar,
and assigning the image index value to the
ImageIndex property each
ToolBarButton. You can then
assign text to be displayed underneath or to the
right of the image by
setting the
Text property of the
ToolBarButton.
ToolBar
control added to
this form - ToolBar1
- Add the
MainMenu control,
MainMenu1
The
MainMenu control represents the container for
the menu structure of a form.
A menu is composed of
MenuItem objects that represent the individual menu
commands in the menu structure.
Each MenuItem can be
a command for your application or a parent menu
for other submenu
items.
Add to this menu - MainMenu1 the
following items
menu
MainMenu1
Item |
Name |
Text |
1
1.1 1.2
1.3
1.4
1.5
2
2.1 |
Menutools
Menubooknote Menuagenda
Menucal
Menuintroductory
Menuabout
Menuexit
Menuquit |
tools
book
note agenda
calculator
introductory
about
work 2010
exit
quit |
| | | |
|
mainform.vb file, the
code ...
|
|
Public
Class
mainform
Inherits
System.Windows.Forms.Form
Dim fintro
As
New
introductory
Dim fabout
As
New
about
Dim response
As
MsgBoxResult
Dim msg_inf
As
String
Dim flg_close
As
Boolean
Dim vtime
As
New
System.DateTime
Private
Sub
mainform_Load(ByVal
sender
As
System.Object,
ByVal e
As
System.EventArgs)
Handles
MyBase.Load
Dim var
As
Integer
Me.Lrbt.Left =
Me.ToolBar1.Width
- (Me.Lrbt.Width
+ 30)
Me.Lrbt.Top = 2
Me.ltimer.Left =
Me.Lrbt.Left
+ ((Me.Lrbt.Width
- Me.ltimer.Width)
/ 2)
Me.ltimer.Top =
Me.Lrbt.Top
+ Me.Lrbt.Height
Me.lblb.Width =
Me.Panel1.Width
/ 5
Me.lblb.Left = 4
Me.lblb.Top =
Me.ToolBar1.Top
+ Me.ToolBar1.Height
+ 6
Me.Panel1.Left =
Me.lblb.Left
Me.Panel1.Top =
Me.lblb.Top
Me.Panel1.Height =
Me.Height
- (Me.ToolBar1.Height
* 6 / 2)
Me.Panel11.Width =
Me.Panel1.Width
Me.Btntools.Width =
Me.Panel11.Width
Me.Panel11.Height =
Me.Panel1.Height
- (Me.Btntools.Height
* 1) + 8
Me.Panel11.Left = 0
Me.Pic_booknote.Left
= Me.Pic_calculator.Left
Me.Pic_agenda.Left =
Me.Pic_calculator.Left
Me.Pic_intro.Left =
Me.Pic_calculator.Left
Me.Pic_about.Left =
Me.Pic_about.Left
var = ( Me.Panel11.Height
- (Me.Pic_calculator.Height
* 5)) / 7
Me.Pic_calculator.Top
= var
Me.Pic_booknote.Top
= Me.Pic_calculator.Top
+ Me.Pic_calculator.Height
+ var
Me.Pic_agenda.Top =
Me.Pic_booknote.Top
+ Me.Pic_booknote.Height
+ var
Me.Pic_intro.Top =
Me.Pic_agenda.Top
+ Me.Pic_agenda.Height
+ var
Me.Pic_about.Top =
Me.Pic_intro.Top
+ Me.Pic_intro.Height
+ var
Me.Lrbt.Visible =
True
Me.ltimer.Visible =
True
'Current directory/Path
current_path =
"C:\work_VBNet_10"
flg_close =
True
End
Sub
Private
Sub
mainform_Closing(ByVal
sender
As
Object,
ByVal
e As
System.ComponentModel.CancelEventArgs)
Handles
MyBase.Closing
If flg_close =
True
Then
msg_inf =
"are you
sure want to exit work .net"
response = MsgBox(msg_inf,
MsgBoxStyle.DefaultButton2
Or
MsgBoxStyle.Information
Or
MsgBoxStyle.YesNo,
Title)
flg_close =
False
'Gets the result of the MessageBox display.
If (response =
MsgBoxResult.Yes)
Then
Me.Close()
End
If
If (response =
MsgBoxResult.No)
Then
e.Cancel =
True
flg_close =
True
End
If
End
If
End
Sub
Private
Sub
mainform_MouseMove(ByVal
sender
As
Object,
ByVal
e As
System.Windows.Forms.MouseEventArgs)
Handles
MyBase.MouseMove
Me.Panel1.Visible =
False
End
Sub
Private
Sub
Timer1_Tick(ByVal
sender
As
System.Object,
ByVal e
As
System.EventArgs)
Handles Timer1.Tick
'
Time ...
Me.ltimer.Text =
Date.Now.ToLongTimeString.ToString
End
Sub
Private
Sub
lblb_MouseMove(ByVal
sender
As
Object,
ByVal
e As
System.Windows.Forms.MouseEventArgs)
Handles
lblb.MouseMove
Me.Panel1.Visible =
True
Sub_Top1()
End
Sub
Private
Sub
Btntools_Click(ByVal
sender
As
System.Object,
ByVal e
As
System.EventArgs)
Handles
Btntools.Click
Sub_Top1()
End
Sub
Private
Sub
Sub_Top1()
Me.Panel11.Visible =
True
Me.Btntools.Top = 4
End
Sub
Private
Sub
Menucal_Click(ByVal
sender
As
System.Object,
ByVal e
As
System.EventArgs)
Handles
Menucal.Click
Dim fcalculator
As
New
calculator
fcalculator.ShowDialog()
End
Sub
Private
Sub
Menubooknote_Click(ByVal
sender
As
System.Object,
ByVal e
As
System.EventArgs)
Handles
Menubooknote.Click
fbooknote.ShowDialog()
End
Sub
Private
Sub
Menuagenda_Click(ByVal
sender
As
System.Object,
ByVal e
As
System.EventArgs)
Handles
Menuagenda.Click
Active_Flag =
True
fagenda.Refresh()
fagenda.ShowDialog()
End
Sub
Private
Sub
Menuintroductory_Click(ByVal
sender
As
System.Object,
ByVal e
As
System.EventArgs)
Handles
Menuintroductory.Click
fintro.ShowDialog()
End
Sub
Private
Sub
Menuabout_Click(ByVal
sender
As
System.Object,
ByVal e
As
System.EventArgs)
Handles
Menuabout.Click
fabout.ShowDialog()
End
Sub
Private
Sub
Menuquit_Click(ByVal
sender
As
System.Object,
ByVal e
As
System.EventArgs)
Handles
Menuquit.Click
sub_close()
End
Sub
Private
Sub
sub_close()
If flg_close =
True
Then
msg_inf =
"are you
sure want to exit Work .net"
response = MsgBox(msg_inf,
MsgBoxStyle.DefaultButton2
Or
MsgBoxStyle.Information
Or
MsgBoxStyle.YesNo,
Title)
flg_close =
False
'Gets the result of the MessageBox display.
If (response =
MsgBoxResult.Yes)
Then
Me.Close()
End
If
If (response =
MsgBoxResult.No)
Then
flg_close =
True
End
If
End
If
End
Sub
Private
Sub
ToolBar1_ButtonClick(ByVal
sender
As
System.Object,
ByVal e
As
System.Windows.Forms.ToolBarButtonClickEventArgs)
Handles
ToolBar1.ButtonClick
Select
Case
Me.ToolBar1.Buttons.IndexOf(e.Button)
Case 2
'
calculator
Menucal_Click(sender, e)
Case 5
'
book note
Menubooknote_Click(sender, e)
Case 8
'
agenda
Menuagenda_Click(sender, e)
Case 11
'
introductory
fintro.ShowDialog()
Case 14
'
about work .Net
fabout.ShowDialog()
End
Select
End
Sub
Private
Sub
Pic_calculator_Click(ByVal
sender
As
System.Object,
ByVal e
As
System.EventArgs)
Handles
Pic_calculator.Click
Me.Panel1.Visible =
False
'
calculator
Menucal_Click(sender, e)
End
Sub
Private
Sub
Pic_booknote_Click(ByVal
sender
As
System.Object,
ByVal e
As
System.EventArgs)
Handles
Pic_booknote.Click
Me.Panel1.Visible =
False
'
book note
Menubooknote_Click(sender, e)
End
Sub
Private
Sub
Pic_agenda_Click(ByVal
sender
As
System.Object,
ByVal e
As
System.EventArgs)
Handles
Pic_agenda.Click
Me.Panel1.Visible =
False
'
agenda
Menuagenda_Click(sender, e)
End
Sub
Private
Sub
Pic_intro_Click(ByVal
sender
As
System.Object,
ByVal e
As
System.EventArgs)
Handles
Pic_intro.Click
Me.Panel1.Visible =
False
'
introductory
Me.Menuintroductory_Click(sender,
e)
End
Sub
Private
Sub
Pic_about_Click(ByVal
sender
As
System.Object,
ByVal e
As
System.EventArgs)
Handles
Pic_about.Click
Me.Panel1.Visible =
False
'
about work .net
Me.Menuabout_Click(sender,
e)
End
Sub
End
Class
| | |
|
|