SPForm class

Represents a form creating, displaying, or editing a list item in a list.

Inheritance hierarchy

System.Object
  Microsoft.SharePoint.SPForm

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Public Class SPForm
'Usage
Dim instance As SPForm
public class SPForm

Remarks

Use the Forms property of the SPList class to return an SPFormCollection object that represents the collection of forms for a list, and use an indexer to return a single form from the collection. For example, if the collection is assigned to a variable named collForms, use collForms[index] in C#, or collForms(index) in Visual Basic, where index is either the index number of the form in the collection or the name of the form page.

Examples

The following code example iterates through all forms for the Contacts list of the current site and displays their site-relative URLs and types.

Dim site As SPWeb = SPControl.GetContextWeb(Context)
Dim list As SPList = site.Lists("Contacts")
Dim forms As SPFormCollection = list.Forms
Dim form As SPForm

For Each form In  forms
    Response.Write(form.Url & " :: " & form.Type & "<BR>")
Next form
SPWeb oWebsite = SPContext.Current.Web;
SPList oList = oWebsite.Lists["Contacts"];
SPFormCollection collForms = oList.Forms;
foreach (SPForm oForm in collForms)
{
    Response.Write(oForm.Url + " :: " + oForm.Type + "<BR>");
}

Thread safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See also

Reference

SPForm members

Microsoft.SharePoint namespace