Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Version number in Winform form text

How can I insert the assembly version number (which I set to auto increment) into a Winform form text?

like image 443
Andrew Avatar asked Aug 24 '11 16:08

Andrew


People also ask

How do I change the version number in Visual Studio?

Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio. Select the Configuration Properties > Linker > General property page. Modify the Version property.

How do I change my winform name?

To change the name of your form, select it in the solution explorer and press F2. Then type in the new name for that form (don't forget the '.

How do you duplicate or copy in winform?

Press "Ctrl" and drag your mouse to duplicate a existing form class file. Then exlude the existing form class file from the project.

Is WinForms deprecated?

WinForms won't be deprecated until Win32 is ... which could be quite sometime! WPF on the other hand has few direct dependencies on Win32 so could potentially form the basis of a "fresh start" UI layer on a future version of windows.


2 Answers

Either of these will work:

var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;  this.Text = String.Format("My Application Version {0}", version);  string version = System.Windows.Forms.Application.ProductVersion;  this.Text = String.Format("My Application Version {0}", version); 

Assuming this is run on the Form you wish to display the text on

like image 97
Iain Ward Avatar answered Oct 11 '22 18:10

Iain Ward


Text = Application.ProductVersion 

Quick way to get the full version as a string (e.g. "1.2.3.4")

like image 37
bytedev Avatar answered Oct 11 '22 17:10

bytedev