HtmlElement.Focusing HtmlElement.Focusing HtmlElement.Focusing HtmlElement.Focusing Event

定義

要素が初めてユーザーの入力フォーカスを得たときに発生します。Occurs when the element first receives user input focus.

public:
 event System::Windows::Forms::HtmlElementEventHandler ^ Focusing;
public event System.Windows.Forms.HtmlElementEventHandler Focusing;
member this.Focusing : System.Windows.Forms.HtmlElementEventHandler 
Public Custom Event Focusing As HtmlElementEventHandler 

このメンバーの使用例を次のコード例に示します。The following code example demonstrates the use of this member. この例では、イベントハンドラーがFocusingイベントの発生を報告します。In the example, an event handler reports on the occurrence of the Focusing event. このレポートは、イベントがいつ発生し、デバッグに役立つかを理解するのに役立ちます。This report helps you to learn when the event occurs and can assist you in debugging.

コード例を実行するには、という名前HtmlElement HtmlElement1の型のインスタンスを含むプロジェクトに貼り付けます。To run the example code, paste it into a project that contains an instance of type HtmlElement named HtmlElement1. 次に、イベントハンドラーがFocusingイベントに関連付けられていることを確認します。Then ensure that the event handler is associated with the Focusing event.

private void HtmlElement1_Focusing(Object sender, HtmlElementEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "MouseButtonsPressed", e.MouseButtonsPressed );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ClientMousePosition", e.ClientMousePosition );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "OffsetMousePosition", e.OffsetMousePosition );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "MousePosition", e.MousePosition );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "BubbleEvent", e.BubbleEvent );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "KeyPressedCode", e.KeyPressedCode );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "AltKeyPressed", e.AltKeyPressed );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "CtrlKeyPressed", e.CtrlKeyPressed );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ShiftKeyPressed", e.ShiftKeyPressed );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "EventType", e.EventType );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ReturnValue", e.ReturnValue );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "FromElement", e.FromElement );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ToElement", e.ToElement );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "Focusing Event" );
}
Private Sub HtmlElement1_Focusing(sender as Object, e as HtmlElementEventArgs) _ 
     Handles HtmlElement1.Focusing

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "MouseButtonsPressed", e.MouseButtonsPressed)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ClientMousePosition", e.ClientMousePosition)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "OffsetMousePosition", e.OffsetMousePosition)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "MousePosition", e.MousePosition)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "BubbleEvent", e.BubbleEvent)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "KeyPressedCode", e.KeyPressedCode)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "AltKeyPressed", e.AltKeyPressed)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "CtrlKeyPressed", e.CtrlKeyPressed)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ShiftKeyPressed", e.ShiftKeyPressed)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "EventType", e.EventType)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ReturnValue", e.ReturnValue)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "FromElement", e.FromElement)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ToElement", e.ToElement)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"Focusing Event")

End Sub

注釈

ユーザーがタスクバーまたは ALT + TAB キーを使用して別のアプリケーションに切り替えられる前にフォーカスFocusingGotFocusあった要素は、ユーザーがアプリケーションに切り替えたときに、イベントとイベントを再び受け取ります。An element that had focus before the user switched to another application using the taskbar or the ALT+TAB keys will receive the Focusing and GotFocus events again when the user switches back to your application.

このイベントの既定の動作を取り消すことはできません。You cannot cancel the default behavior of this event. 要素からフォーカスを削除するにはFocusGotFocusイベント内から別の要素に対してを呼び出します。To remove focus from an element, call Focus on a different element from within the GotFocus event.

HtmlDocument BubbleEventまた、 HtmlElementEventArgsクラスのプロパティをに設定しない限り、要素のイベントは、その要素の親およびクラス自体でも発生します。true FocusingA Focusing event on an element will also occur on that element's parents and on the HtmlDocument class itself, unless you set the BubbleEvent property of the HtmlElementEventArgs class to true.

適用対象

こちらもご覧ください