PropertyGrid.ToolbarVisible 屬性

定義

取得或設定值,指出工具列是否為可見。

C#
public virtual bool ToolbarVisible { get; set; }

屬性值

如果工具列為可見的,則為 true,否則為 false。 預設為 true

範例

下列程式碼範例示範如何使用 PropertySortToolbarVisible 屬性初始化 PropertyGrid 控制項。 此外,本範例會將 控制項的 Visible 屬性設定 PropertyGridfalse ,以便在執行範例時看不到方格。 若要執行此範例,請將下列程式碼貼到表單中,並從表單的建構函式或 Load 事件處理方法呼叫 InitializePropertyGrid 方法。 若要在執行表單時檢視屬性方格,請將格線的 Visible 屬性變更為 true 、重新編譯,然後重新執行表單。

C#

// Declare a propertyGrid.
internal PropertyGrid propertyGrid1;

// Initialize propertyGrid1.
private void InitializePropertyGrid()
{
    propertyGrid1 = new PropertyGrid();
    propertyGrid1.Name = "PropertyGrid1";
    propertyGrid1.Location = new System.Drawing.Point(185, 20);
    propertyGrid1.Size = new System.Drawing.Size(150, 300);
    propertyGrid1.TabIndex = 5;

    // Set the sort to alphabetical and set Toolbar visible
    // to false, so the user cannot change the sort.
    propertyGrid1.PropertySort = PropertySort.Alphabetical;
    propertyGrid1.ToolbarVisible = false;
    propertyGrid1.Text = "Property Grid";

    // Add the PropertyGrid to the form, but set its
    // visibility to False so it will not appear when the form loads.
    propertyGrid1.Visible = false;
    this.Controls.Add(propertyGrid1);
}

適用於

產品 版本
.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