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

Home
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.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » GUI Windows Forms » MaskedTextBox 
23.18.1.Set the input mask to that of a short time
Set the input mask to that of a short time
using System;
using System.Threading;
using System.Windows.Forms;

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

public partial class MaskedTextBoxShortTimeForm : Form
{

    public MaskedTextBoxShortTimeForm()
    {
        InitializeComponent();
    }

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

    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)
    {
    }

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

}
partial class MaskedTextBoxShortTimeForm
{
    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 = "MaskedTextBoxShortTimeForm";
        this.Text = "MaskedTextBoxShortTimeForm";
        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;
}
23.18.MaskedTextBox
23.18.1.Set the input mask to that of a short timeSet the input mask to that of a short time
23.18.2.Set the input mask to that of a US ZIP codeSet the input mask to that of a US ZIP code
23.18.3.Set the input mask to that of a UK postcodeSet the input mask to that of a UK postcode
23.18.4.Set the input mask to that of currencySet the input mask to that of currency
23.18.5.Set the input mask to that of a short dateSet the input mask to that of a short date
23.18.6.Set the input mask to that of a secret PINSet the input mask to that of a secret PIN
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.