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

包含控制項的組件的檔案版本。

屬性

範例

下列程式碼範例會顯示 包含在 中 Label Form 之 應用程式的相關資訊。 此範例需要 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 Forms功能,讓 Application.UserAppDataPath 撰寫符合「Windows 認證」程式的應用程式更容易。

適用於

另請參閱