stu nicholls dot com | menu - Professional dropdown #3



click here


Date Time Picker: Enables the user to select a date and time and display it in a specified format.

MonthCalender: Displays the monthly calendar from which the user can select a date.

In the following example TextBox, DateTimePicker, MonthCalendar and few Label controls are added as shown in Fig. 4. Whenever a date is entered in the text box it is displayed at the location of Label1. Whenver a Date is picked from the DateTimePicker then it is displayed at the locaion of Label2 and time is disoplayed at the location of Label7. Whenver a Date is selected from MonthCalendar then the selected date is displayed at the location of Label3, all these are shown in Fig. 5

Public Class Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
' This will Check and display only the valid dates.
If (IsDate(TextBox1.Text) = True) Then
Label1.Text=
Date.Parse(TextBox1.Text).ToShortDateString
Else
Label1.Text = ""
End If
End Sub

Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
' This will Show the selected date.
Label2.Text = DateTimePicker1.Value.ToShortDateString
' This will Show the selected time
Label7.Text = DateTimePicker1.Value.ToLongTimeString
End Sub
Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged
' This will Show the selected date.
Label3.Text=MonthCalendar1.SelectionStart.ToLongDateString
End Sub
End Class

Fig11


Fig12


PageSetupDialog: Displays a dialog box that enables the user to change the page related print settings, including margin settings and paper orientation (shown in Fig. 6).
'This is used to display the Printer setting Dialog box
'we are using the code to generate the PrintSetupDialog 'control
Imports System.IO
Imports System.Windows.Forms
Public Class Form1
Public Prt As New PrinterSetupDialogSettings()
Public Class PrinterSetupDialogSettings
Public Sub PrtSettings()
Dim PrintTest As New PrintDialog()
PrintTest.Document = New System.Drawing.Printing.PrintDocument()
If (PrintTest.ShowDialog() = DialogResult.OK) Then
MessageBox.Show("Printer: " & PrintTest.PrinterSettings.PrinterName)
MessageBox.Show("From Page: " & PrintTest.PrinterSettings.FromPage)
MessageBox.Show("To Page: " & PrintTest.PrinterSettings.ToPage)
MessageBox.Show("Print Range: " & PrintTest.PrinterSettings.PrintRange)
MessageBox.Show("Copies: " & PrintTest.PrinterSettings.Copies)
If (PrintTest.PrinterSettings.LandscapeAngle = 90) Then
MessageBox.Show("Landscape")
Else
MessageBox.Show("Portrait")
End If
MessageBox.Show("Allow Print to File: " & PrintTest.AllowPrintToFile)
MessageBox.Show("AllowSelection: " & PrintTest.AllowSelection)
MessageBox.Show("Allow Some Pages: " & PrintTest.AllowSomePages)
MessageBox.Show("Print to File: " & PrintTest.PrintToFile)
MessageBox.Show("Show Network: " & PrintTest.ShowNetwork)
End If
End Sub
End Class

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Prt.PrtSettings()
End Sub
End Class

Fig13


'page setup dialog box
'PageStUp.ShowDialog() will display the dialog box for page 'settting and the your selection is 'displayed using the message box
Public Class PageSetUp
Public Shared pg As New PageSetupDialogSettings()
Public Class PageSetupDialogSettings
Public Sub PgSetup()
Dim PageStUp As New PageSetupDialog()
PageStUp.Document = New
System.Drawing.Printing.PrintDocument()
If (PageStUp.ShowDialog() = DialogResult.OK) Then
MessageBox.Show("Allow Margins: " & PageStUp.AllowMargins)
MessageBox.Show("Allow Orientation: " & PageStUp.AllowOrientation)
MessageBox.Show("Allow Printer: " & PageStUp.AllowPrinter)
MessageBox.Show("Minimum Margins: " & PageStUp.MinMargins.ToString())
MessageBox.Show("Show Network: " & PageStUp.ShowNetwork)
MessageBox.Show("Printer Settings: " & PageStUp.PrinterSettings.ToString())
PageStUp.PageSettings.ToString())
End If
End Sub
End Class

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
pg.PgSetup()
End Sub
End Class

Fig14


<< Previous   Next>>


comments powered by Disqus
click here
click here
Footer1