Search code examples
winformsvisual-studio-express

Loading Application With Different Title on Load


Not sure if this is at all possible, but is there any way that, as soon as I start my application, that the title bar will change? So there is always a different title?

So, say my application title is called: Test Application: Instance 1, then ext time I load the application, the title will change to: Test Application: Instance 2, etc.

I am using Visual Studio Express 2015 for Windows Desktop.

I have just started this project, so has the default form load function:

namespace Application
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    }
}

This doesn't work = Form.load

I don't know what else to try or if it is at all possible.

So, I don't know if it is possible, because how do you know when to stop it counting? Or maybe only stop once it hits 10 application hits?

Basically, I want the same form, but a different title name.


Solution

  • Provide a handler for the Load event on your main form and set the Text property to the title you desire:

    string newTitle = MethodWhichGeneratesTitleText(); 
    this.Text = newTitle;
    

    In this method you can check your database, config file or other sources that help you determine the title you need.