TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

<< Back to C-SHARP

C# Text Property: Windows Forms

Use the Text property in Windows Forms to change the window title.
Text is a property with many meanings. It is available on Windows Forms controls (Form, TextBox). You can get and set this property to change the string that stores the text for the control. Controls implement Text differently.
Example. In this program, we use a TextBox as well the default Form. For more information about these controls, please see the appropriate articles. We assign the Text property of the enclosing Form (this) and the TextBox instance (textBox1).Form
C# program that uses Text property using System; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // Form has a Text property. this.Text = "The Dev Codes"; // TextBox has a Text property. textBox1.Text = "Thanks"; } } }
You can see the results of this program in the screenshot. The title bar text of the window has its text changed to "The Dev Codes". And the TextBox contains the string "Thanks". Text is implemented in different ways.

Tip: The Text property can be assigned to a string variable reference, or a string literal.

StringString Literal
Summary. Knowing how to use the Text property on a Form (as with this.Text) is confusing because we often don't think of the title bar as text. The Text property becomes even more confusing when other controls implement it a different way.
© TheDeveloperBlog.com
The Dev Codes

Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf