This is a toolbar created to create mapunitpoly templates. Is there a reason that other values beside the defaults don't save? Also I have a problem when editing that some of the templates get deleted and can't be recovered. Is there anyway to stop this from happening?
public static void UpdateMapUnitPolysFeatureTemplates(IWorkspace theWorkspace)<BR /> {<BR /> // Get the MapUnitPolys Layer from the ToC<BR /> IFeatureLayer theLayer = commonFunctions.FindFeatureLayer(theWorkspace, "MapUnitPolys");<BR /><BR /> // If the layer was not found, don't try and update the templates!<BR /> if (theLayer == null) { return; }<BR /><BR /> // Get a reference to the template editor, remove current templates<BR /> IEditor3 templateEditor = (IEditor3)ArcMap.Editor;<BR /> templateEditor.RemoveAllTemplatesInLayer((ILayer)theLayer);<BR /><BR /> // Get the DMU entries<BR /> var sortedDmu = GetDmuSortedByHierarchy(theWorkspace);<BR /><BR /> // Loop through the DMU, add templates to an array<BR /> IArray templateArray = new ArrayClass();<BR /> foreach (KeyValuePair<string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> anEntry in sortedDmu)<BR /> {<BR /> // Get this DMU entry<BR /> DescriptionOfMapUnitsAccess.DescriptionOfMapUnit dmuEntry = anEntry.Value;<BR /><BR /> // Build the template if this is not a heading<BR /> if (dmuEntry.ParagraphStyle.Contains("Heading") == true) { continue; }<BR /> IEditTemplateFactory templateFactory = new EditTemplateFactoryClass();<BR /> IEditTemplate newTemplate = templateFactory.Create(dmuEntry.MapUnit + " - " + dmuEntry.Name, (ILayer)theLayer);<BR /><BR /> // Set the Template's default values<BR /> newTemplate.SetDefaultValue("MapUnit", dmuEntry.MapUnit, false);<BR /> newTemplate.SetDefaultValue("Label", dmuEntry.Label, false);<BR /> newTemplate.SetDefaultValue("IdentityConfidence", "certain", false);<BR /><BR /> // Add the template to the array<BR /> templateArray.Add(newTemplate);<BR /> }