Control.ProductName 属性

获取包含控件的程序集的产品名称。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public ReadOnly Property ProductName As String
用法
Dim instance As Control
Dim value As String

value = instance.ProductName
public string ProductName { get; }
public:
property String^ ProductName {
    String^ get ();
}
/** @property */
public String get_ProductName ()
public function get ProductName () : String

属性值

包含控件的程序集的产品名称。

备注

ProductName 属性为只读属性。若要更改此属性的值,请设置 AssemblyProductAttributeProduct 属性值。下面的 C# 代码行设置 ProductName 属性。

 [assembly: AssemblyProduct("MyApplication")]

提示

强烈建议您提供公司名称、产品名称和产品版本。提供此信息将使您能够使用 Application.UserAppDataPath 等 Windows 窗体功能,从而可以更方便地编写符合“Certified for Windows”(Windows 认证)计划的应用程序。有关 Windows 认证计划的更多信息,请访问 https://msdn.microsoft.com/certification.。

示例

下面的代码示例显示 Form 包含的 Label 中的应用程序的有关信息。此示例要求已设置了 CompanyNameProductNameProductVersion

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
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;  
}
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.set_Text(this.get_CompanyName() + "  " 
        + this.get_ProductName() + "  Version: " 
        + this.get_ProductVersion());
} //AboutDialog_Load

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

Control 类
Control 成员
System.Windows.Forms 命名空间
AssemblyProductAttribute.Product