VB.Net by API/System.Windows.Forms/DateTimePickerFormat

Материал из VB Эксперт
Перейти к: навигация, поиск

DateTimePickerFormat.Short

  
Imports System.Windows.Forms
public class DataTimePickerFormat
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class
Public Class Form1
    Inherits System.Windows.Forms.Form
    Public Sub New()
        MyBase.New()
        InitializeComponent()
    End Sub
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Private components As System.ruponentModel.IContainer
    Friend WithEvents DateTimePicker1 As System.Windows.Forms.DateTimePicker
    Friend WithEvents ComboBox1 As System.Windows.Forms.ruboBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.DateTimePicker1 = New System.Windows.Forms.DateTimePicker
        Me.ruboBox1 = New System.Windows.Forms.ruboBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.SuspendLayout()
        "
        "DateTimePicker1
        "
        Me.DateTimePicker1.Location = New System.Drawing.Point(40, 24)
        Me.DateTimePicker1.Name = "DateTimePicker1"
        Me.DateTimePicker1.Size = New System.Drawing.Size(120, 20)
        Me.DateTimePicker1.TabIndex = 0
        "
        "ComboBox1
        "
        Me.ruboBox1.Items.AddRange(New Object() {"Long", "Short", "Custom", "Time"})
        Me.ruboBox1.Location = New System.Drawing.Point(40, 200)
        Me.ruboBox1.Name = "ComboBox1"
        Me.ruboBox1.Size = New System.Drawing.Size(120, 21)
        Me.ruboBox1.TabIndex = 1
        "
        "Label1
        "
        Me.Label1.Location = New System.Drawing.Point(40, 160)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(80, 24)
        Me.Label1.TabIndex = 2
        Me.Label1.Text = "Format"
        "
        "Form1
        "
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.ruboBox1)
        Me.Controls.Add(Me.DateTimePicker1)
        Me.Name = "Form1"
        Me.Text = "DateTimePicker"
        Me.ResumeLayout(False)
    End Sub
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.SelectedIndex < 0 Then
            Return
        End If
        Dim caption As String = ComboBox1.SelectedItem.ToString().Chars(0)
        Dim format As DateTimePickerFormat
        Select Case caption
            Case "S"c
                format = DateTimePickerFormat.Short
            Case "T"c
                format = DateTimePickerFormat.Time
            Case "C"c
                format = DateTimePickerFormat.Custom
            Case Else
                format = DateTimePickerFormat.Long
        End Select
        DateTimePicker1.Format = format
    End Sub
End Class