本文整理汇总了C#中System.Windows.Forms.HtmlElement.GotFocus事件的典型用法代码示例。如果您正苦于以下问题:C# HtmlElement.GotFocus事件的具体用法?C# HtmlElement.GotFocus怎么用?C# HtmlElement.GotFocus使用的例子?那么恭喜您, 这里精选的事件代码示例或许可以为您提供帮助。您也可以进一步了解该事件所在类System.Windows.Forms.HtmlElement
的用法示例。
在下文中一共展示了HtmlElement.GotFocus事件的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleFormFocus
HtmlElement targetFormElement;
private void HandleFormFocus()
{
if (webBrowser1.Document != null)
{
HtmlDocument doc = webBrowser1.Document;
if (doc.Forms.Count > 0)
{
HtmlElement targetForm = doc.Forms[0];
HtmlElementCollection searchCollection = targetForm.All.GetElementsByName("text1");
if (searchCollection.Count == 1)
{
targetFormElement = searchCollection[0];
}
}
}
}
private void TargetFormElement_Focus(Object sender, HtmlElementEventArgs e)
{
HtmlElement textElement = e.FromElement;
String elementText = textElement.GetAttribute("value");
// Check that this value is at least five characters long.
if (elementText.Length < 5)
{
e.ReturnValue = true;
MessageBox.Show("The entry in the current field must be at least five characters long.");
}
}