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

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

// 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 イベントを処理してタイトル バーのタイトルを更新します。

適用対象

こちらもご覧ください