Control.ProductVersion 属性

定义

获取包含控件的程序集的版本。

public:
 property System::String ^ ProductVersion { System::String ^ get(); };
[System.ComponentModel.Browsable(false)]
public string ProductVersion { get; }
[<System.ComponentModel.Browsable(false)>]
member this.ProductVersion : string
Public ReadOnly Property ProductVersion As String

属性值

String

包含控件的程序集的文件版本。

属性

示例

下面的代码示例显示有关包含的应用程序LabelForm的信息。 本示例要求 CompanyName设置并 ProductName ProductVersion 已设置。

void AboutDialog_Load( Object^ /*sender*/, EventArgs^ /*e*/ )
{
   // Display the application information in the label.
   this->labelVersionInfo->Text = String::Format(  "{0} {1} Version: {2}", this->CompanyName, this->ProductName, this->ProductVersion );
}
private void AboutDialog_Load(object sender, EventArgs e)
{
   // Display the application information in the label.
   this.labelVersionInfo.Text = 
      this.CompanyName + "  " + 
      this.ProductName + "  Version: " +
      this.ProductVersion;  
}
Private Sub AboutDialog_Load(sender As Object, e As EventArgs) Handles MyBase.Load
   ' Display the application information in the label.
   Me.labelVersionInfo.Text = _
      Me.CompanyName + "  " + _
      Me.ProductName + "  Version: " + _
      Me.ProductVersion
   End Sub

注解

ProductVersion 属性是只读属性。 若要更改此属性的值,请设置 VersionAssemblyVersionAttribute属性的属性值。 以下 C# 代码行设置属性 ProductVersion

[assembly: AssemblyVersion("1.0.1")]  

备注

强烈建议提供公司名称、产品名称和产品版本。 通过提供此信息,可以使用Windows 窗体功能,以便Application.UserAppDataPath更轻松地编写符合“Windows 认证”计划的应用程序。

适用于

另请参阅