HtmlDocument.Forms Proprietà

Definizione

Ottiene un insieme di tutti gli <elementi FORM> nel documento.

public:
 property System::Windows::Forms::HtmlElementCollection ^ Forms { System::Windows::Forms::HtmlElementCollection ^ get(); };
public System.Windows.Forms.HtmlElementCollection Forms { get; }
member this.Forms : System.Windows.Forms.HtmlElementCollection
Public ReadOnly Property Forms As HtmlElementCollection

Valore della proprietà

HtmlElementCollection

Oggetto HtmlElementCollection degli <elementi FORM> all'interno del documento.

Esempio

Nell'esempio di codice seguente viene eseguito l'iterazione di tutti gli elementi in una pagina Web e viene cancellato tutto l'input Form dell'utente, impostando nuovamente i moduli sui valori predefiniti.

private void ResetForms()
{
    if (webBrowser1.Document != null)
    {
        foreach (HtmlElement form in webBrowser1.Document.Forms)
        {
            form.InvokeMember("reset");
        }
    }
}
Private Sub ResetForms()
    If (Not (WebBrowser1.Document Is Nothing)) Then
        For Each FormElem As HtmlElement In WebBrowser1.Document.Forms
            FormElem.InvokeMember("reset")
        Next
    End If
End Sub

Commenti

Un documento HTML può avere uno o più FORM elementi con campi di input per l'invio dei dati a un server.

È possibile inviare un oggetto FORM a livello di codice ottenendone HtmlElement e chiamando il relativo Submit metodo usando il InvokeMember metodo .

Per aggiungere un nuovo FORM oggetto a un documento, è possibile creare un nuovo FORM tag come stringa e assegnarlo alla InnerHtml proprietà di un elemento aggiunto in precedenza al DOM HTML oppure è possibile utilizzare il CreateElement metodo , impostarne le proprietà usando SetAttributee aggiungerlo come figlio di un elemento esistente utilizzando AppendChild.

Si applica a

Vedi anche