How do you change the text in the Titlebar in Windows Forms?
Solution 1:
For changing the Title of a form at runtime we can code as below
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
this.Text = "This Is My Title";
}
}
Solution 2:
You can change the text in the titlebar in Windows Forms by using the Text
property.
For C#
// This class is added to the namespace containing the Form1 class.
class MainApplication
{
public static void Main()
{
// Instantiate a new instance of Form1.
Form1 f1 = new Form1();
// Display a messagebox. This shows the application
// is running, yet there is nothing shown to the user.
// This is the point at which you customize your form.
System.Windows.Forms.MessageBox.Show("The application "
+ "is running now, but no forms have been shown.");
// Customize the form.
f1.Text = "Running Form";
// Show the instance of the form modally.
f1.ShowDialog();
}
}
Solution 3:
All the answers that include creating an new object from Form
class are absolutely creating new form
. But you can use Text
property of ActiveForm
subclass in Form
class. For example:
public Form1()
{
InitializeComponent();
Form1.ActiveForm.Text = "Your Title";
}