Set the input mask to that of a short date : MaskedTextBox « GUI Windows Forms « C# / CSharp Tutorial

C# / CSharp Tutorial
1. Language Basics
2. Data Type
3. Operator
4. Statement
5. String
6. struct
7. Class
8. Operator Overload
9. delegate
10. Attribute
11. Data Structure
12. Assembly
13. Date Time
14. Development
15. File Directory Stream
16. Preprocessing Directives
17. Regular Expression
18. Generic
19. Reflection
20. Thread
21. I18N Internationalization
22. GUI Windows Forms
23. 2D
24. Design Patterns
25. Windows
26. XML
27. ADO.Net
28. Network
29. Directory Services
30. Security
31. unsafe
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C# / CSharp Tutorial » GUI Windows Forms » MaskedTextBox 
22. 18. 5. Set the input mask to that of a short date
Set the input mask to that of a short date
using System;
using System.Threading;
using System.Windows.Forms;

public class MaskedTextBoxShortDateFormDemo{
    [STAThread]
    public static void Main(string[] args)
    {
        Application.Run(new MaskedTextBoxShortDateForm());
    }
}

public partial class MaskedTextBoxShortDateForm : Form
{

    public MaskedTextBoxShortDateForm()
    {
        InitializeComponent();
    }

    private void btnTime_Click(object sender, EventArgs e)
    {
    }

    private void btnUSZip_Click(object sender, EventArgs e)
    {
    }

    private void btnUKPost_Click(object sender, EventArgs e)
    {
    }

    private void btnCurrency_Click(object sender, EventArgs e)
    {
    }

    private void btnDate_Click(object sender, EventArgs e)
    {
        this.mskTextBox.UseSystemPasswordChar = false;
        this.mskTextBox.Mask = "00/00/0000";
        this.lblActiveMask.Text = this.mskTextBox.Mask;
        this.mskTextBox.Focus();
    }

    private void btnSecret_Click(object sender, EventArgs e)
    {
    }

}
partial class MaskedTextBoxShortDateForm
{
    private System.ComponentModel.IContainer components = null;

    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    private void InitializeComponent()
    {
        this.mskTextBox = new System.Windows.Forms.MaskedTextBox();
        this.label1 = new System.Windows.Forms.Label();
        this.lblActiveMask = new System.Windows.Forms.Label();
        this.btnTime = new System.Windows.Forms.Button();
        this.btnUSZip = new System.Windows.Forms.Button();
        this.btnCurrency = new System.Windows.Forms.Button();
        this.btnUKPost = new System.Windows.Forms.Button();
        this.btnDate = new System.Windows.Forms.Button();
        this.btnSecret = new System.Windows.Forms.Button();
        this.SuspendLayout();

        this.mskTextBox.BeepOnError = true;
        this.mskTextBox.Location = new System.Drawing.Point(1541);
        this.mskTextBox.Name = "mskTextBox";
        this.mskTextBox.Size = new System.Drawing.Size(26520);
        this.mskTextBox.TabIndex = 1;

        this.label1.AutoSize = true;
        this.label1.Location = new System.Drawing.Point(1223);
        this.label1.Name = "label1";
        this.label1.Size = new System.Drawing.Size(9413);
        this.label1.TabIndex = 2;
        this.label1.Text = "Active input mask:";

        this.lblActiveMask.AutoSize = true;
        this.lblActiveMask.Location = new System.Drawing.Point(11223);
        this.lblActiveMask.Name = "lblActiveMask";
        this.lblActiveMask.Size = new System.Drawing.Size(5113);
        this.lblActiveMask.TabIndex = 3;
        this.lblActiveMask.Text = "Any input";

        this.btnTime.Location = new System.Drawing.Point(1585);
        this.btnTime.Name = "btnTime";
        this.btnTime.Size = new System.Drawing.Size(8323);
        this.btnTime.TabIndex = 4;
        this.btnTime.Text = "24-hour time";
        this.btnTime.UseVisualStyleBackColor = true;
        this.btnTime.Click += new System.EventHandler(this.btnTime_Click);

        this.btnUSZip.Location = new System.Drawing.Point(15130);
        this.btnUSZip.Name = "btnUSZip";
        this.btnUSZip.Size = new System.Drawing.Size(8323);
        this.btnUSZip.TabIndex = 5;
        this.btnUSZip.Text = "US ZIP";
        this.btnUSZip.UseVisualStyleBackColor = true;
        this.btnUSZip.Click += new System.EventHandler(this.btnUSZip_Click);

        this.btnCurrency.Location = new System.Drawing.Point(10485);
        this.btnCurrency.Name = "btnCurrency";
        this.btnCurrency.Size = new System.Drawing.Size(8723);
        this.btnCurrency.TabIndex = 7;
        this.btnCurrency.Text = "Currency";
        this.btnCurrency.UseVisualStyleBackColor = true;
        this.btnCurrency.Click += new System.EventHandler(this.btnCurrency_Click);

        this.btnUKPost.Location = new System.Drawing.Point(104130);
        this.btnUKPost.Name = "btnUKPost";
        this.btnUKPost.Size = new System.Drawing.Size(8723);
        this.btnUKPost.TabIndex = 8;
        this.btnUKPost.Text = "UK Postcode";
        this.btnUKPost.UseVisualStyleBackColor = true;
        this.btnUKPost.Click += new System.EventHandler(this.btnUKPost_Click);

        this.btnDate.Location = new System.Drawing.Point(19785);
        this.btnDate.Name = "btnDate";
        this.btnDate.Size = new System.Drawing.Size(8323);
        this.btnDate.TabIndex = 10;
        this.btnDate.Text = "Short Date";
        this.btnDate.UseVisualStyleBackColor = true;
        this.btnDate.Click += new System.EventHandler(this.btnDate_Click);

        this.btnSecret.Location = new System.Drawing.Point(197130);
        this.btnSecret.Name = "btnSecret";
        this.btnSecret.Size = new System.Drawing.Size(8323);
        this.btnSecret.TabIndex = 11;
        this.btnSecret.Text = "Secret PIN";
        this.btnSecret.UseVisualStyleBackColor = true;
        this.btnSecret.Click += new System.EventHandler(this.btnSecret_Click);

        this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(292196);
        this.Controls.Add(this.btnSecret);
        this.Controls.Add(this.btnDate);
        this.Controls.Add(this.btnUKPost);
        this.Controls.Add(this.btnCurrency);
        this.Controls.Add(this.btnUSZip);
        this.Controls.Add(this.btnTime);
        this.Controls.Add(this.lblActiveMask);
        this.Controls.Add(this.label1);
        this.Controls.Add(this.mskTextBox);
        this.Name = "MaskedTextBoxShortDateForm";
        this.Text = "MaskedTextBoxShortDateForm";
        this.ResumeLayout(false);
        this.PerformLayout();

    }
    private System.Windows.Forms.MaskedTextBox mskTextBox;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.Label lblActiveMask;
    private System.Windows.Forms.Button btnTime;
    private System.Windows.Forms.Button btnUSZip;
    private System.Windows.Forms.Button btnCurrency;
    private System.Windows.Forms.Button btnUKPost;
    private System.Windows.Forms.Button btnDate;
    private System.Windows.Forms.Button btnSecret;
}
22. 18. MaskedTextBox
22. 18. 1. Set the input mask to that of a short timeSet the input mask to that of a short time
22. 18. 2. Set the input mask to that of a US ZIP codeSet the input mask to that of a US ZIP code
22. 18. 3. Set the input mask to that of a UK postcodeSet the input mask to that of a UK postcode
22. 18. 4. Set the input mask to that of currencySet the input mask to that of currency
22. 18. 5. Set the input mask to that of a short dateSet the input mask to that of a short date
22. 18. 6. Set the input mask to that of a secret PINSet the input mask to that of a secret PIN
w___ww_.__j_ava_2s_._c___o___m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.