WebBrowser.DocumentTitle プロパティ

定義

WebBrowser コントロールに現在表示されているドキュメントのタイトルを取得します。

public:
 property System::String ^ DocumentTitle { System::String ^ get(); };
[System.ComponentModel.Browsable(false)]
public string DocumentTitle { get; }
[<System.ComponentModel.Browsable(false)>]
member this.DocumentTitle : string
Public ReadOnly Property DocumentTitle As String

プロパティ値

現在のドキュメントのタイトル。ドキュメントが読み込まれていない場合は、空の文字列 ("")。

属性

例外

この WebBrowser インスタンスは無効になっています。

IWebBrowser2 インターフェイスの実装への参照を、基になる ActiveX WebBrowser コントロールから取得できませんでした。

次のコード例では、 プロパティを DocumentTitle 使用して、フォームタイトルバーを現在のドキュメントのタイトルで更新する方法を示します。 この例では、フォームに というコントロールwebBrowser1WebBrowser含まれている必要があります。

完全なコード例については、「方法: Windows フォーム アプリケーションに Web ブラウザー機能を追加する」を参照してください。

// Updates the title bar with the current document title.
void WebBrowser1_DocumentTitleChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   this->Text = WebBrowser1->DocumentTitle;
}
// Updates the title bar with the current document title.
private void webBrowser1_DocumentTitleChanged(object sender, EventArgs e)
{
    this.Text = webBrowser1.DocumentTitle;
}
' Updates the title bar with the current document title.
Private Sub webBrowser1_DocumentTitleChanged( _
    ByVal sender As Object, ByVal e As EventArgs) _
    Handles webBrowser1.DocumentTitleChanged

    Me.Text = webBrowser1.DocumentTitle

End Sub

注釈

このプロパティは、たとえば、アプリケーションのタイトル バーにドキュメント タイトルを表示する場合に便利です。 現在のドキュメントにタイトルが定義されていない場合、このプロパティはドキュメントの場所とファイル名に設定されます。

イベントを DocumentTitleChanged 処理して、コントロールが新しいドキュメントに移動したときに WebBrowser タイトル バーのタイトルを更新します。

適用対象

こちらもご覧ください