PropertyGridEditorPart.Title 屬性

定義

取得或設定編輯器控制項的標題。

public:
 virtual property System::String ^ Title { System::String ^ get(); void set(System::String ^ value); };
public override string Title { get; set; }
member this.Title : string with get, set
Public Overrides Property Title As String

屬性值

做為控制項標題的字串。 預設值是 Web 組件控制項集合所提供的計算控制項名稱。

範例

此程式碼範例示範如何使用 Title 控制項的 PropertyGridEditorPart 屬性。 如需執行範例所需的完整程式碼,請參閱類別概觀主題的 PropertyGridEditorPart 範例一節。

下列程式碼範例示範如何在網頁中以宣告方式在控制項上 PropertyGridEditorPart 設定標題。

<asp:EditorZone ID="EditorZone1" runat="server">
  <ZoneTemplate>
    <asp:PropertyGridEditorPart ID="PropertyGridEditorPart1" 
      runat="server" 
      Title="Edit Custom Properties"
      OnPreRender="PropertyGridEditorPart1_PreRender" 
      OnInit="PropertyGridEditorPart1_Init" />   
  </ZoneTemplate>
</asp:EditorZone>
<asp:EditorZone ID="EditorZone1" runat="server">
  <ZoneTemplate>
    <asp:PropertyGridEditorPart ID="PropertyGridEditorPart1" 
      runat="server" 
      Title="Edit Custom Properties"
      OnPreRender="PropertyGridEditorPart1_PreRender" 
      OnInit="PropertyGridEditorPart1_Init" />   
  </ZoneTemplate>
</asp:EditorZone>

程式碼範例的下一個部分示範如何以程式設計方式設定 屬性的值 Title 。 為了保存以程式設計方式指派的值,會使用名為 editControlTitle 的靜態變數,而且每次初始化控制項時,都會將此值指派給 Title 屬性,以便在回傳事件之間保存值。

private static String editControlTitle;

protected void Button1_Click(object sender, EventArgs e)
{
  editControlTitle = Server.HtmlEncode(TextBox1.Text);
  PropertyGridEditorPart1.Title = editControlTitle;
}

protected void PropertyGridEditorPart1_Init(object sender, EventArgs e)
{
  if (editControlTitle != null)
    PropertyGridEditorPart1.Title = editControlTitle;
}  
Shared editControlTitle As String

Protected Sub Button1_Click(ByVal sender As Object, _
  ByVal e As System.EventArgs)
  editControlTitle = Server.HtmlEncode(TextBox1.Text)
  PropertyGridEditorPart1.Title = editControlTitle 
End Sub

Protected Sub PropertyGridEditorPart1_Init(ByVal _
  sender As Object, ByVal e As System.EventArgs)
  If Not editControlTitle Is Nothing Then
    PropertyGridEditorPart1.Title = editControlTitle
  End If
End Sub

當您在瀏覽器中載入頁面時,您可以在 [顯示模式] 下拉式清單控制項中選取 [編輯模式],以切換至編輯模式。 您可以按一下動詞功能表, ([ 使用者資訊 WebPart ] 控制項標題列中的向下箭號) ,然後按一下 [ 編輯 ] 開始編輯。 當編輯使用者介面 (UI) 可見時,您可以看到 PropertyGridEditorPart 控制項,以及位於該控制項上方的按鈕和文字方塊。 請注意,控制項的 PropertyGridEditorPart 標題是在網頁的宣告式標記中指派給控制項的值。 如果您在 [更新編輯器][元件標題 ] 按鈕旁的文字方塊中輸入一些文字,然後按一下按鈕,控制項的標題就會更新。

備註

Title當控制項在編輯模式中可見時,屬性值會顯示在控制項的 PropertyGridEditorPart 標題列中。 當控制項在頁面中宣告時,您可以設定 屬性的值 Title 。 如果您未提供標題的值,則會提供特定文化特性的預設值。

屬性 Title 會覆寫基底屬性,如此一來,如果沒有提供標題值,Web 元件控制項集就可以提供適合 PropertyGridEditorPart 控制項的預設標題。

適用於

另請參閱