I have this piece of code in my routine but it doesnt seem to work:
public MainForm()
{
InitializeComponent();
this.Text = "Elvis " + AssemblyVersion;
}
In my designer I had set the form title to "Elvis". I see that the AssemblyVersion info gets added to the text properly but the title doesnt get updated at all. I've tried refresh, invalidate etc, but nothing works. Any idea how I can update the title at runtime?
I am using .NET 3.5 and VS 2008.
thanks
To rename a form, you can open the form and click the title to edit it, it changes the form name as well.
You can change the text in the titlebar in Windows Forms by using the Text property.
You can use the Form. Invalidate(); or Form. Refresh(); methods.
Right-click Form1. vb in the Solution Explorer window (the window above the Properties window). Choose Rename from the context menu that appears.
This generally works just fine. Setting the Text
property of a Form will change the title of the window. So can you post more code? It's possible your Text property is later getting overwritten without you realizing it.
I had the same issue and it was because of the Initialize components function that is changing the form's header, if you set the header using the constructor, it will be overwritten with the InitializeComponents function value. Solution: remove the form's property set in the InitializeComponent function.
Best regards, Chen
Try to put this
this.Text = "Elvis " + AssemblyVersion;
on the onload event
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With