Поделиться через


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

<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public Class SPForm

Dim instance As SPForm
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
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