Article
    C#
    ADO.Net
    .NET
    ASP.Net & Web Forms
    Custom Controls
    Web Development
    Exception Handling
    XML
    Database
    Security in .Net
    Testing
    Web Services
    Windows Services
    Windows Controls
    WCF
    AJAX
    WPF
    XAML
    Reporting
    Setup
    VB.Net
    LINQ
    JQuery
    SilverLight
    JavaScript
    HTML5
    Crystal Report
    Cloud Computing
    Share Point
    Visual C++
    MVC
    Android
    PHP
    Java
    HTML
    WordPress
    Joomla
    Products
    Drupal
    Windows Phone
    JSON
    LightSwitch
    iPhone/iPad
    Ruby on Rails
    IIS 7
    Windows 8
    CSS/CSS3
    Excel
    MS Access
    Shortcut Keys
    Visual SourceSafe
    Team Foundation Server
    API(s)
    Sencha-Touch
    Single Page App
    Bootstrap
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Top Contributor
Advertisement
Advertise with Us
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog

Home >> VB.Net >> DateTimePicker Control in VB.Net
DateTimePicker Control in VB.Net
DateTimePicker Control in VB.Net


by Pushpendra Singh on 12/14/2010 9:20:34 PM

Views: 14494       Comments: 0

DateTimePicker Control in VB.Net

A DateTimePicker control allows you to select a date and time.

Drag and drop DateTimePicker control form toolbox on window Form.

DateTimePicker Control in VB.Net

Code:

' DateTimePicker ValueChanged Event Hander

Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged

        'Display the selected Date in Label

        Label2.Text = DateTimePicker1.Text

    End Sub

 

Run the project

DateTimePicker Control in VB.Net

When you click on the calendar icon in the control then calendar popup will show.

DateTimePicker Control in VB.Net

When you select the date then ValueChanged event will fire and selected date will be show in Label.

DateTimePicker Control in VB.Net

DateTimePicker Properties:

Format: we can set DateTimePicker Format in which Format it should show.

 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Display the date in Short Format

        DateTimePicker1.Format = DateTimePickerFormat.Short

    End Sub

At run time DateTimePicker value will show in short Format.

DateTimePicker Control in VB.Net

Show checkbox:

You can make a DateTimePicker control editable where you can change the value without using the Calendar. This can be done by setting ShowCheckBox property to true.

 

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ' Makes DateTimePicker editable

        DateTimePicker1.ShowCheckBox = True   

    End Sub

DateTimePicker Control in VB.Net

Checkbox will show in DateTimePicker.You can edit the value in DateTimePicker and changed value will show in Label.

ShowUpDown

We can also use an up-down control to set the date and time.

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

       

        'UpDown control will show in DateTimePicker

        DateTimePicker1.ShowUpDown = True

    End Sub

DateTimePicker Control in VB.Net

UpDown Control   is display in DateTimePicker.we can change date through Updown.

Report Abuse Form
Reason:    
 

Title :
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
     
 
Latest Article by Pushpendra SinghRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Latest BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 5086
Advertisement
MindStick SurveyManager
Advertise with Us
  
Copyright © 2009 - 2014MindStick. All Rights Reserved.