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
包含控件的程序集的产品名称。
- 属性
下面的代码示例在 包含Form的 中Label显示有关应用程序的信息。 此示例要求 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 窗体功能(例如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 |