Control.ProductName 屬性
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得包含控制項的組件的產品名稱。
public:
property System::String ^ ProductName { System::String ^ get(); };
C#
[System.ComponentModel.Browsable(false)]
public string ProductName { get; }
[<System.ComponentModel.Browsable(false)>]
member this.ProductName : string
Public ReadOnly Property ProductName As String
包含控制項的組件的產品名稱。
- 屬性
下列程式碼範例會顯示 包含在 中 LabelForm 應用程式的相關資訊。 這個範例需要 CompanyName 設定 和 ProductNameProductVersion 。
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 );
}
C#
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
屬性 ProductName 是唯讀屬性。 若要變更此屬性的值,請設定 Product 的 AssemblyProductAttribute 屬性值。 下列 C# 程式程式碼會 ProductName 設定 屬性。
[assembly: AssemblyProduct("MyApplication")]
注意
強烈建議您提供公司名稱、產品名稱和產品版本。 提供這項資訊可讓您使用Windows Forms功能,例如 Application.UserAppDataPath ,更輕鬆地撰寫符合「Windows 認證」程式的應用程式。
產品 | 版本 |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |