HtmlElementEventArgs 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
에 정의된 HtmlDocumentHtmlElement이벤트에 대한 데이터를 제공합니다.
public ref class HtmlElementEventArgs sealed : EventArgs
public sealed class HtmlElementEventArgs : EventArgs
type HtmlElementEventArgs = class
inherit EventArgs
Public NotInheritable Class HtmlElementEventArgs
Inherits EventArgs
- 상속
예제
다음 코드 예제에서는 이 형식을 사용하는 방법을 보여 줍니다. 이 예제에서 이벤트 처리기는 이벤트의 발생을 보고합니다 Click . 이 보고서는 이벤트가 발생하는 시기를 파악하는 데 도움이 되며 디버깅에 도움이 될 수 있습니다. 여러 이벤트 또는 자주 발생하는 이벤트에 대해 보고하려면 메시지를 여러 줄Show로 Console.WriteLine 대체 TextBox 하거나 추가해 보세요.
예제 코드를 실행하려면 이름이 지정된 HtmlDocument형식 HtmlDocument1 의 인스턴스가 포함된 프로젝트에 붙여넣습니다. 그런 다음 이벤트 처리기가 이벤트와 연결되어 있는지 확인합니다 Click .
private void HtmlDocument1_Click(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(), "Click Event" );
}
Private Sub HtmlDocument1_Click(sender as Object, e as HtmlElementEventArgs) _
Handles HtmlDocument1.Click
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(),"Click Event")
End Sub
설명
HtmlElementEventArgs 는 관리되지 않는 HTML DOM에 대해 프로그래밍하거나 HTML 페이지에 대한 window.event 활성 스크립트를 작성할 때 개체에 있는 것과 동일한 정보를 캡슐화합니다.
대부분의 경우 이벤트 동작 ToElement 을 수신하는 HTML 요소를 찾고 남아 있는 HTML 요소를 찾는 데 사용할 FromElement 수 있습니다. 그러나 모든 이벤트가 이러한 속성에 대한 값을 제공하는 것은 아닙니다.
HTML DOM의 많은 이벤트는 취소되지 않는 한 부모 요소로 전송됩니다. 이를 이벤트 버블링이라고합니다. 클릭을 SPAN 수신하는 DIV 경우 첫 번째, HTML 페이지의 SPAN 요소에 대한 DIVBODY클릭 이벤트가 발생합니다.
BubbleEvent 는 이벤트가 이러한 방식으로 동작하는지 여부를 제어합니다.
속성
| Name | Description |
|---|---|
| AltKeyPressed |
이 이벤트가 발생했을 때 ALT 키를 눌렀는지 여부를 나타냅니다. |
| BubbleEvent |
현재 이벤트가 HTML 문서 개체 모델의 요소 계층 구조를 통해 버블링되는지 여부를 나타내는 값을 가져오거나 설정합니다. |
| ClientMousePosition |
문서의 클라이언트 영역에서 마우스 커서의 위치를 가져오거나 설정합니다. |
| CtrlKeyPressed |
이 이벤트가 발생했을 때 Ctrl 키를 눌렀는지 여부를 나타냅니다. |
| EventType |
발생한 이벤트의 이름을 가져옵니다. |
| FromElement |
HtmlElement 마우스 포인터가 멀리 이동하는지 가져옵니다. |
| KeyPressedCode | |
| MouseButtonsPressed | |
| MousePosition |
상대적으로 배치된 부모 요소를 기준으로 마우스 커서의 위치를 가져오거나 설정합니다. |
| OffsetMousePosition |
이벤트를 발생시키는 요소를 기준으로 마우스 커서의 위치를 가져오거나 설정합니다. |
| ReturnValue |
처리된 이벤트의 반환 값을 가져오거나 설정합니다. |
| ShiftKeyPressed |
이 이벤트가 발생했을 때 SHIFT 키를 눌렀는지 여부를 나타냅니다. |
| ToElement |
HtmlElement 사용자가 마우스 포인터를 이동하는 대상을 가져옵니다. |
메서드
| Name | Description |
|---|---|
| Equals(Object) |
지정된 개체가 현재 개체와 같은지 여부를 확인합니다. (다음에서 상속됨 Object) |
| GetHashCode() |
기본 해시 함수로 사용됩니다. (다음에서 상속됨 Object) |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |