You can specify a column in the list definition so that WSS will include this column in the list created by default each time you create a list of this type. The list definition can be included in feature.
After creating a new list, you can use the WSS object model to add a column to the list.
Specify columns in the list definition
To add a column to the list definition (as part of the feature), you must add the required XML elements to the list definition. Then, when you create a list of this type, this column appears in the list created by default.
Steps:
1. In the list definition XML fileFieldsAddFieldElement.
2. Define the field as needed and set the fieldFieldThe attribute of the element.
If you want to modify the columns in the created list, WSS will not write the changes back to the XML column definition. On the contrary, WSS saves the changes to the entries in the WSS database.
Add a column to the created list
We can use the WSS object model to add columns to an existing list through programming.
Procedure:
1. on a specific listFieldsAttribute to access the set in the list bar. This method returnsSpfieldcollectionObject.
2. Add a new column to the list using one of the following methods of the spfieldcollection object:
- Microsoft. Sharepoint. spfieldcollection. Add (Microsoft. Sharepoint. spfield)
- Microsoft. Sharepoint. spfieldcollection. Add (system. String, Microsoft. Sharepoint. spfieldtype, system. Boolean)
- Microsoft. sharepoint. spfieldcollection. add (system. string, Microsoft. sharepoint. spfieldtype, system. boolean, system. boolean, system. collections. specialized. stringcollection)
- Microsoft. Sharepoint. spfieldcollection. addfieldasxml (system. String)
- Microsoft. Sharepoint. spfieldcollection. addfieldasxml (system. String, system. Boolean, Microsoft. Sharepoint. spaddfieldoptions)
- createnewfield (system. String, system. String)