TextBox.Validating : TextBox « System.Windows.Forms « C# / C Sharp by API






TextBox.Validating

  

using System;
using System.Windows.Forms;

class GetValueFromTextBox : Form
{
    private Label label1;
    private TextBox textBox1;
    private Button button1;

    public GetValueFromTextBox() 
    {
        this.label1 = new Label();
        this.textBox1 = new TextBox();
        this.button1 = new Button();

        this.SuspendLayout();

        this.label1.Location = new System.Drawing.Point(16, 36);
        this.label1.Name = "label1";
        this.label1.Size = new System.Drawing.Size(128, 16);
        this.label1.TabIndex = 0;
        this.label1.Text = "Please enter your name:";

        this.textBox1.Location = new System.Drawing.Point(152, 32);
        this.textBox1.Name = "textBox1";
        this.textBox1.TabIndex = 1;
        this.textBox1.Text = "";

        this.button1.Location = new System.Drawing.Point(109, 80);
        this.button1.Name = "button1";
        this.button1.TabIndex = 2;
        this.button1.Text = "Enter";
        this.button1.Click += new System.EventHandler(this.button1_Click);

        this.ClientSize = new System.Drawing.Size(292, 126);
        this.Controls.Add(this.button1);
        this.Controls.Add(this.textBox1);
        this.Controls.Add(this.label1);
        this.Name = "form1";
        this.Text = "";

        this.ResumeLayout(false);    
    }

    private void button1_Click(object sender, System.EventArgs e)
    {
        Console.WriteLine(textBox1.Text);

        MessageBox.Show(textBox1.Text);
    }

    [STAThread]
    public static void Main() 
    {
        Application.EnableVisualStyles();
        Application.Run(new GetValueFromTextBox());
    }
}

   
    
  








Related examples in the same category

1.TextBox.AcceptsTab
2.TextBox.Anchor
3.TextBox.BorderStyle
4.TextBox.CanFocus
5.TextBox.Clear()
6.TextBox.Click
7.TextBox.ContextMenu
8.TextBox.ContainsFocus
9.TextBox.DataBindings
10.TextBox.DoDragDrop
11.TextBox.DragDrop
12.TextBox.DragEnter
13.TextBox.Focus()
14.TextBox.Focused
15.TextBox.GotFocus
16.TextBox.KeyPress
17.TextBox.Lines
18.TextBox.LostFocus
19.TextBox.Multiline
20.TextBox.MouseDown
21.TextBox.PasswordChar
22.TextBox.ScrollBars
23.TextBox.SelectAll()
24.TextBox.SelectedText
25.TextBox.SelectionLength
26.TextBox.TextChanged
27.TextBox.Validated