HtmlElementEventArgs.ToElement 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取用户正将鼠标指针移向的 HtmlElement。
public:
property System::Windows::Forms::HtmlElement ^ ToElement { System::Windows::Forms::HtmlElement ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.HtmlElement ToElement { get; }
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.HtmlElement? ToElement { get; }
[<System.ComponentModel.Browsable(false)>]
member this.ToElement : System.Windows.Forms.HtmlElement
Public ReadOnly Property ToElement As HtmlElement
属性值
鼠标指针移向的元素。
- 属性
示例
下面的代码示例演示了此成员的用法。 在此示例中,事件处理程序报告事件的发生情况 HtmlDocument.Click 。 此报表可帮助你了解事件发生的时间,并可以帮助你进行调试。 若要报告多个事件或频繁发生的事件,请考虑将 MessageBox.Show 替换为 Console.WriteLine 或将消息追加到多行 TextBox。
若要运行示例代码,请将其粘贴到包含名为 HtmlDocument1
的 类型的HtmlDocument实例的项目中。 然后,确保事件处理程序与 HtmlDocument.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
注解
ToElement 在鼠标事件期间,将具有有效的值,例如 MouseEnter 和 MouseLeave。