Label in C# Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report In Windows Forms, Label control is used to display text on the form. It does not interact with user input or handle mouse or keyboard events. Labels are used to provide information to the user within the form such as description, message, or details. These are the key points about labels.Display Text or Image: It is mainly used to show the text or image in form.Non-Interactive: It is non-interactive and just shows the text not like buttons and textbox.Positioning: Labels can be placed anywhere on the form we can use drag and drop and also specify their coordinates using code.Auto-Size: Labels can automatically adjust their size and fit according to the content when we set the AutoSize property as true.Ways To Create Labels in Windows FormsThere are mainly two ways to create labels in the Windows Forms:Design Time (Drag and drop)Run Time (Custom code)Design Time ( Drag and drop)This is the easiest way to create labels in Windows Forms using Visual Studio we just have to open the toolbox and drag and drop the label on the form in the designer and further we can change the appearance of the label using the properties. Follow these steps to create a label. Step 1: Now locate the project with the name here we are using the default name which is Form1 and it will open a form in the editor that we can further modify. In the image, we have two files that are open one Design and there is Form1.cs these two play a major role. We use the Form 1.cs file for the custom logic.Step 2: Now open a Toolbox go to the view > Toolbox or ctrl + alt + x. Step 3: Choose labels from the common controls in Toolbox as shown below: And then drag-and-drop in the form: Step 4. Now open the properties of the label, press right-click on the label and go to properties it will open Solution Explorer now we can change the appearance and behaviour of the label in properties. Now we can change the appearance and behaviour of the label such as background and text color or font size. These are the changes we made to the label Similarly, we can create different labels here is the outputOutput: Run Time (Custom Code)In this method, we are going to modify the Form1.cs file and add custom code modification in C# to change the appearance of the button according to our requirements. Follow these step-by-step processes.Step 1: Create a label using the Label() constructor provided by the Label class.// Creating label using Label classLabel mylab = new Label();Step 2: After creating the Label, set the properties of the Label provided by the Label class.// Set the text in Labelmylab.Text = "GeeksforGeeks";// Set the location of the Labelmylab.Location = new Point(222, 90);// Set the AutoSize property of the Label controlmylab.AutoSize = true;// Set the font of the content present in the Label Controlmylab.Font = new Font("Calibri", 18);// Set the foreground color of the Label controlmylab.ForeColor = Color.Green;// Set the padding in the Label control mylab.Padding = new Padding(6);Step 3: And last add this Label control to form using the Add() method.// Add this label to the formthis.Controls.Add(mylab);Step 4: Now double-click on the form in Design and it will open the Form.cs file where code is written in C#. Here the program file is Form 1.cs Now write this code in Form1.cs fileForm1.cs file: C# namespace WinFormsApp1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // Creating and setting the label Label mylab = new Label(); mylab.Text = "GeeksforGeeks"; mylab.Location = new Point(222, 90); mylab.AutoSize = true; mylab.Font = new Font("Calibri", 18); mylab.ForeColor = Color.Green; mylab.Padding = new Padding(6); // Adding this control to the form this.Controls.Add(mylab); } } } Output: Properties of Label ControlPropertyDescriptionAutoSizeThis property is used to set a value indicating whether the Label control is automatically resized to display its entire contents.BackColorThis property is used to set the background colour for the Label control.BackgroundImageThis property is used to set the background image for the Label control.BorderStyleThis property is used to set the border style for the Label control.FlatStyleThis property is used to set the flat style appearance of the label control.FontThis property is used to set the font of the text displayed by the Label control.FontHeightThis property is used to set the height of the font of the Label control.ForeColorThis property is used to set the foreground colour of the Label control.HeightThis property is used to set the height of the Label control.ImageThis property is used to set the image that is displayed on a Label.LocationThis property is used to set the coordinates of the upper-left corner of the Label control relative to the upper-left corner of its form.NameThis property is used to set the name of the Label control.PaddingThis property is used to set padding within the Label control.SizeThis property is used to set the height and width of the Label control.TextThis property is used to set the text associated with this Label control.TextAlignThis property is used to set the alignment of text in the label.VisibleThis property is used to set a value indicating whether the control and all its child controls are displayed.WidthThis property is used to set the width of the Label control. Comment More infoAdvertise with us Next Article Introduction to .NET Framework A ankita_saini Follow Improve Article Tags : C# Similar Reads IntroductionC# TutorialC# (pronounced "C-sharp") is a modern, versatile, object-oriented programming language developed by Microsoft in 2000 that runs on the .NET Framework. Whether you're creating Windows applications, diving into Unity game development, or working on enterprise solutions, C# is one of the top choices fo 4 min read Introduction to .NET FrameworkThe .NET Framework is a software development framework developed by Microsoft that provides a runtime environment and a set of libraries and tools for building and running applications on Windows operating systems. The .NET framework is primarily used on Windows, while .NET Core (which evolved into 6 min read C# .NET Framework (Basic Architecture and Component Stack)C# (C-Sharp) is a modern, object-oriented programming language developed by Microsoft in 2000. It is a part of the .NET ecosystem and is widely used for building desktop, web, mobile, cloud, and enterprise applications. This is originally tied to the .NET Framework, C# has evolved to be the primary 6 min read C# Hello WorldThe Hello World Program is the most basic program when we dive into a new programming language. This simply prints "Hello World!" on the console. In C#, a basic program consists of the following:A Namespace DeclarationClass Declaration & DefinitionClass Members(like variables, methods, etc.)Main 4 min read Common Language Runtime (CLR) in C#The Common Language Runtime (CLR) is a component of the Microsoft .NET Framework that manages the execution of .NET applications. It is responsible for loading and executing the code written in various .NET programming languages, including C#, VB.NET, F#, and others.When a C# program is compiled, th 4 min read FundamentalsC# IdentifiersIn programming languages, identifiers are used for identification purposes. Or in other words, identifiers are the user-defined name of the program components. In C#, an identifier can be a class name, method name, variable name, or label. Example: public class GFG { static public void Main () { int 2 min read C# Data TypesData types specify the type of data that a valid C# variable can hold. C# is a strongly typed programming language because in C# each type of data (such as integer, character, float, and so forth) is predefined as part of the programming language and all constants or variables defined for a given pr 7 min read C# VariablesIn C#, variables are containers used to store data values during program execution. So basically, a Variable is a placeholder of the information which can be changed at runtime. And variables allows to Retrieve and Manipulate the stored information. In Brief Defination: When a user enters a new valu 4 min read C# LiteralsIn C#, a literal is a fixed value used in a program. These values are directly written into the code and can be used by variables. A literal can be an integer, floating-point number, string, character, boolean, or even null. Example:// Here 100 is a constant/literal.int x = 100; Types of Literals in 5 min read C# OperatorsIn C#, Operators are special types of symbols which perform operations on variables or values. It is a fundamental part of language which plays an important role in performing different mathematical operations. It takes one or more operands and performs operations to produce a result.Types of Operat 7 min read C# KeywordsKeywords or Reserved words are the words in a language that are used for some internal process or represent some predefined actions. These words are therefore not allowed to be used as variable names or objects. Doing this will result in a compile-time error.Example:C#// C# Program to illustrate the 5 min read Control StatementsC# Decision Making (if, if-else, if-else-if ladder, nested if, switch, nested switch)Decision Making in programming is similar to decision making in real life. In programming too, a certain block of code needs to be executed when some condition is fulfilled. A programming language uses control statements to control the flow of execution of program based on certain conditions. These 5 min read C# Switch StatementIn C#, Switch statement is a multiway branch statement. It provides an efficient way to transfer the execution to different parts of a code based on the value of the expression. The switch expression is of integer type such as int, char, byte, or short, or of an enumeration type, or of string type. 4 min read C# LoopsLooping in a programming language is a way to execute a statement or a set of statements multiple times, depending on the result of the condition to be evaluated to execute statements. The result condition should be true to execute statements within loops.Types of Loops in C#Loops are mainly divided 4 min read C# Jump Statements (Break, Continue, Goto, Return and Throw)In C#, Jump statements are used to transfer control from one point to another point in the program due to some specified code while executing the program. In, this article, we will learn to different jump statements available to work in C#.Types of Jump StatementsThere are mainly five keywords in th 4 min read OOP ConceptsC# Class and ObjectsClass and Object are the basic concepts of Object-Oriented Programming which revolve around real-life entities. A class is a user-defined blueprint or prototype from which objects are created. Basically, a class combines the fields and methods(member functions which define actions) into a single uni 5 min read C# ConstructorsConstructor is a special method of the class which gets automatically invoked whenever an instance of the class is created. Constructors in C# are fundamental components of object-oriented programming. Like methods, It contains the collection of instructions that are executed at the time of Object c 5 min read C# InheritanceInheritance is a fundamental concept in object-oriented programming that allows a child class to inherit the properties from the superclass. The new class inherits the properties and methods of the existing class and can also add new properties and methods of its own. Inheritance promotes code reuse 6 min read C# EncapsulationEncapsulation in C# is the process of wrapping data and methods that operate on that data within a single unit. It is the mechanism that binds together the data and the functions that manipulate them. It acts as a protective shield that prevents direct access to the internal representation of an obj 4 min read C# AbstractionData Abstraction is the property by which only the essential details are shown to the user and non-essential details or implementations are hidden from the user. In other words, Data Abstraction may also be defined as the process of identifying only the required characteristics of an object ignoring 4 min read MethodsC# MethodsA method is a block of code that performs a specific task. It can be executed when called, and it may take inputs, process them, and return a result. Methods can be defined within classes and are used to break down complex programs into simpler, modular pieces. Methods improve code organization, rea 4 min read C# Method OverloadingMethod overloading is an important feature of Object-Oriented programming and refers to the ability to redefine a method in more than one form. A user can implement method overloading by defining two or more functions in a class sharing the same name. C# can distinguish the methods with different me 4 min read C# | Method ParametersMethods in C# are generally the block of codes or statements in a program which gives the user the ability to reuse the same code which ultimately saves the excessive use of memory, acts as a time saver and more importantly, it provides better readability of the code. So you can say a method is a co 7 min read C# Method OverridingIn C#, method overriding occurs when a subclass provides a specific implementation for a method that is already defined in the superclass or base class. The method in the subclass must have the same signature as the method in the base class. By overriding a method, the subclass can modify the behavi 9 min read Anonymous Method in C#An anonymous method is a method which doesnât contain any name which is introduced in C# 2.0. It is useful when the user wants to create an inline method and also wants to pass parameter in the anonymous method like other methods. An Anonymous method is defined using the delegate keyword and the use 3 min read ArraysC# ArraysAn array is a group of like-typed variables that are referred to by a common name. And each data item is called an element of the array. The data types of the elements may be any valid data type like char, int, float, etc. and the elements are stored in a contiguous location. Length of the array spe 8 min read C# Jagged ArraysA jagged array is an array of arrays, where each element in the main array can have a different length. In simpler terms, a jagged array is an array whose elements are themselves arrays. These inner arrays can have different lengths. Can also be mixed with multidimensional arrays. The number of rows 4 min read C# Array ClassArray class in C# is part of the System namespace and provides methods for creating, searching, and sorting arrays. The Array class is not part of the System.Collections namespace, but it is still considered as a collection because it is based on the IList interface. The Array class is the base clas 7 min read How to Sort an Array in C# | Array.Sort() Method Set - 1Array.Sort Method in C# is used to sort elements in a one-dimensional array. There are 17 methods in the overload list of this method as follows:Sort<T>(T[]) MethodSort<T>(T[], IComparer<T>) MethodSort<T>(T[], Int32, Int32) MethodSort<T>(T[], Comparison<T>) Method 8 min read How to find the rank of an array in C#Array.Rank Property is used to get the rank of the Array. Rank is the number of dimensions of an array. For example, 1-D array returns 1, a 2-D array returns 2, and so on. Syntax: public int Rank { get; } Property Value: It returns the rank (number of dimensions) of the Array of type System.Int32. B 2 min read ArrayListArrayList in C#ArrayList is a powerful feature of C# language. It is the non-generic type of collection which is defined in System.Collections namespace. It is used to create a dynamic array means the size of the array is increase or decrease automatically according to the requirement of your program, there is no 6 min read C# ArrayList ClassArrayList class in C# is a part of the System.Collections namespace that represents an ordered collection of an object that can be indexed individually. It is basically an alternative to an array. It also allows dynamic memory allocation, adding, searching, and sorting items in the list.Elements can 7 min read C# | Array vs ArrayListArrays: An array is a group of like-typed variables that are referred to by a common name. Example: CSHARP // C# program to demonstrate the Arrays using System; class GFG { // Main Method public static void Main(string[] args) { // creating array int[] arr = new int[4]; // initializing array arr[0] 2 min read StringC# StringsIn C#, a string is a sequence of Unicode characters or an array of characters. The range of Unicode characters will be U+0000 to U+FFFF. The array of characters is also termed as the text. So the string is the representation of the text. A string is an important concept, and sometimes people get con 7 min read C# Verbatim String Literal - @In C#, a verbatim string is created using a special symbol @. The symbol(@) is known as a verbatim identifier. If a string contains @ as a prefix followed by double quotes, then compiler identifies that string as a verbatim string and compile that string. The main advantage of @ symbol is to tell th 5 min read C# String ClassIn C#, a string is a sequence of Unicode characters or an array of characters. The range of Unicode characters will be U+0000 to U+FFFF. The array of characters is also termed as the text. So the string is the representation of the text. A string is represented by a class System.String. The String c 9 min read C# StringBuilderStringBuilder is a Dynamic Object. It doesnât create a new object in the memory but dynamically expands the needed memory to accommodate the modified or new string.A String object is immutable, i.e. a String cannot be changed once created. To avoid string replacing, appending, removing or inserting 4 min read C# String vs StringBuilderStringBuilder is used to represent a mutable string of characters. Mutable means the string which can be changed. So String objects are immutable but StringBuilder is the mutable string type. It will not create a new modified instance of the current string object but do the modifications in the exis 3 min read TupleC# TupleA tuple is a data structure which consists of multiple parts. It is the easiest way to represent a data set which has multiple values of different types. It was introduced in .NET Framework 4.0. In a tuple, we can add elements from 1 to 8. If try to add elements greater than eight, then the compiler 7 min read C# Tuple ClassIn C#, the Tuple class is used to provide static methods for creating tuples and this class is defined under the System namespace. This class itself does not represent a tuple, but it provides static methods that are used to create an instance of the tuple type. In other words, the Tuple class provi 3 min read C# ValueTupleValueTuple is a structure introduced in C# 7.0 which represents the value type. Already included in .NET Framework 4.7 or higher version. It allows us to store a data set that contains multiple values that may or may not be related to each other. It can store elements starting from 0 to 8 and can st 7 min read C# ValueTuple StructValueTuple Struct in C# is a structure that provides static methods that are used in creating value tuples. It is defined under the System namespace and was introduced in .NET Framework 4.7. This struct enables runtime implementation tuples in C#. The ValueTuple structure represents a tuple that can 4 min read IndexersC# IndexersIn C#, an indexer allows an instance of a class or struct to be indexed as an array. When an indexer is defined for a class, then that class will behave like a virtual array. Array access operator i.e. ([ ]) is used to access the instance of the class which uses an indexer. A user can retrieve or se 4 min read C# Multidimensional IndexersIn C#, indexers are special members that allow objects to be indexed similarly to arrays. Multi-dimensional indexers in C# are the same as multidimensional arrays. We can efficiently retrieve data with a multi-dimensional indexer by providing at least two parameters in its declaration. The first ind 5 min read C# - Overloading of IndexersIn C#, Indexer allows an instance of a class or struct to be indexed as an array. When an indexer is defined for a class, then that class will behave like a virtual array. It can be overloaded. C# has multiple indexers in a single class. To overload an indexer, declare it with multiple parameters an 3 min read Like