HtmlElementCollection.Count Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the number of elements in the collection.
public:
property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer
Property Value
An Int32 representing the number of elements in the collection.
Implements
Examples
The following code example finds a FORM
object using its name, and submits its data to the server programmatically. The code example requires that your application hosts a WebBrowser control named webBrowser1
.
private void SubmitForm(String formName)
{
HtmlElementCollection elems = null;
HtmlElement elem = null;
if (webBrowser1.Document != null)
{
HtmlDocument doc = webBrowser1.Document;
elems = doc.All.GetElementsByName(formName);
if (elems != null && elems.Count > 0)
{
elem = elems[0];
if (elem.TagName.Equals("FORM"))
{
elem.InvokeMember("Submit");
}
}
}
}
Private Sub SubmitForm(ByVal FormName As String)
Dim Elems As HtmlElementCollection
Dim Elem As HtmlElement
If (WebBrowser1.Document IsNot Nothing) Then
With WebBrowser1.Document
Elems = .All.GetElementsByName(FormName)
If (Not Elems Is Nothing And Elems.Count > 0) Then
Elem = Elems(0)
If (Elem.TagName.Equals("FORM")) Then
Elem.InvokeMember("Submit")
End If
End If
End With
End If
End Sub
Applies to
Співпраця з нами на GitHub
Джерело цього вмісту можна знайти на GitHub, де також можна створювати й переглядати запитання та запити на внесення змін. Докладні відомості наведено в нашому посібнику для співавторів.