Presentation is loading. Please wait.

Presentation is loading. Please wait.

VB.NET Additional Topics

Similar presentations


Presentation on theme: "VB.NET Additional Topics"— Presentation transcript:

1 VB.NET Additional Topics
Programming In Visual Basic.NET

2 Timer Control Place the control from the Toolbox on the form
Appears in the Component Tray Prefix – tmr Interval property Between 0 and 65,535 milliseconds 1,000 milliseconds = 1 second Enabled property False (default) ==> Do not run Tick event True ==> Run Tick event at designated interval Tick event Runs as a loop, with iterations repeated every time the designated Interval elapses © 2001 by The McGraw-Hill Companies, Inc. All rights reserved.

3 Moving Controls with Timer
Use SetBounds to move or change size of a control Example: Moving control with Timer ctrName.SetBounds(intX, intY, intWidth, intHeight) Private Sub tmrMove_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrMove.Tick Const intSHIFT As Integer = 3I If mintX <= 400 And mintY <= 400 Then mintX += intSHIFT : mintY += intSHIFT picPlane.SetBounds(mintX, mintY, 30, 30) Else mintX = 0 : mintY = 0 tmrMove.Enabled = False End If End Sub © 2001 by The McGraw-Hill Companies, Inc. All rights reserved.

4 MDI versus SDI SDI = Single-Document Interface
All we have created thus far Each form is in a separate window that acts independently form the other forms MDI = Multiple-Document Interface Like Word, Excel, etc. Forms display within the window of other forms © 2001 by The McGraw-Hill Companies, Inc. All rights reserved.

5 Examining an MDI Application
© 2001 by The McGraw-Hill Companies, Inc. All rights reserved.

6 MDI (Multiple-Document Interface)
Parent form (main window) which "contains" other windows Many Child forms (document windows) "contained within" Parent window Parent and and active Child share menus Window menu Tile, Cascade, Arrange Icons, and Window List © 2001 by The McGraw-Hill Companies, Inc. All rights reserved. 4

7 MDI Environments Close Parent and all Child forms close also
Child forms not allowed to "wander" out of the Parent's area; Child ALWAYS inside Parent Can combine MDI and SDI in VB Splash forms are usually not child forms Can have several documents open at one time accessible from Window menu © 2001 by The McGraw-Hill Companies, Inc. All rights reserved.

8 Creating MDI Projects At design time designate a form as Parent
IsMdiContainer property = True At run time designate Child forms Before displaying the Child form from the Parent set the Child's MdiParent property to the parent form Add a Window menu frmChildOne.MdiParent = Me © 2001 by The McGraw-Hill Companies, Inc. All rights reserved. 5

9 Designating Child Form
Private Sub mnuDisplayChildOne_Click(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles mnuDisplayChildOne.Click 'Display Child One Dim frmChildOne As New frmChildOne( ) frmChildOne.MdiParent = Me frmChildOne.Show End Sub © 2001 by The McGraw-Hill Companies, Inc. All rights reserved.

10 Adding a Window Menu Parent form should include a Window menu to
Allow the user to arrange multiple Child forms Allow the user to switch between windows Lists open Child forms set menu's MdiList Property to True © 2001 by The McGraw-Hill Companies, Inc. All rights reserved.

11 Window Menu Arrange Options
Use the LayoutMdi method to set the type of layout Examples Me.LayoutMdi(MdiLayout.TileHorizontal) Me.LayoutMdi(MdiLayout.TileVertical) Me.LayoutMdi(MdiLayout.Cascade) © 2001 by The McGraw-Hill Companies, Inc. All rights reserved.

12 Displaying the Date and Time
Now property holds system date and time Use DateTime methods: Generally set initial values in Form_load and use Timer to update the time Now.ToShortDateString Now.ToLongDateString Now.ToShortTimeString Now.ToLongTimeString lblDate.Text = Now.ToShortDateString lblTime.Text = Now.ToShortTimeString © 2001 by The McGraw-Hill Companies, Inc. All rights reserved.

13 Calendar Controls DateTimePicker MonthCalendar
© 2001 by The McGraw-Hill Companies, Inc. All rights reserved.

14 DateTimePicker Control
Value Property Contains the date Initially set to current date User can select a date or your program can assign a date ValueChanged Event Prefix - dtm © 2001 by The McGraw-Hill Companies, Inc. All rights reserved.


Download ppt "VB.NET Additional Topics"

Similar presentations


Ads by Google