C # Self-study Road 21

Source: Internet
Author: User

21. Text Box control

The textbox is the most common and simplest text display and input control.

1. Common Properties.

The A.text property. The text displayed, set the text alignment by TextAlign.

The B.backcolor property. Sets the background color of the text box.

C.forecolor property to set the foreground color of the text box.

D.font property to set the properties of the font.

E.passwordchar property, the letter entered will be masking by the specified word.

The f.enable and visible properties.

The G.readonly property, whether read-only.

H.multiline property, whether it contains more than a row.


2. Common methods.

A.clear method, clear the text in the text box.

B.appendtext method, append text at the end of the text.


3. Common events.


A.textchanged event. The event is triggered when the content of the text changes.

The B.enter event, which triggers the event when the text box gets the focus.

The C.leave event, when the text box loses focus, triggers the event.


Using System;

Using System.Collections.Generic;

Using System.ComponentModel;

Using System.Data;

Using System.Drawing;

Using System.Linq;

Using System.Text;

Using System.Threading.Tasks;

Using System.Windows.Forms;


Namespace WindowsFormsApplication6

{

public partial class Form1:form

{

Public Form1 ()

{

InitializeComponent ();

}


private void textBox1_TextChanged (object sender, EventArgs e)

{

This.label1.Text = This.textBox1.Text;

}


private void Textbox2_textchanged (object sender, EventArgs e)

{


}


private void Form1_Load (object sender, EventArgs e)

{

This.textBox1.ForeColor = Color.Blue;

This.textBox1.BackColor = Color.White;

This.textBox2.ForeColor = Color.green;

This.textBox2.BackColor = Color.White;

This.textBox2.ReadOnly = true;

}


private void TextBox1_Enter (object sender, EventArgs e)

{

This.textBox1.Clear ();

}


private void Textbox1_leave (object sender, EventArgs e)

{

This.textBox2.AppendText (This.textBox1.Text + Environment.NewLine);

}

}

}



650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/60/0D/wKiom1Uqd-GhBXKhAACqBtOihA0337.jpg "title=" S ' U] 5i43l}{z_x ' V{v2w0wn.png "alt=" Wkiom1uqd-ghbxkhaacqbtoiha0337.jpg "/>

This article from "Very blog" blog, reproduced please contact the author!

C # Self-study path

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.