SPForm class

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


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

public class SPForm

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.

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

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>");

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