How to apply the default form to an object

Unofficial Content

You can apply the default form to any part of an object with the following code:

...

KBObject myObject = ...;

List<KBObjectPart> parts = new List<KBObjectPart>() { myObject.Parts[typeof(WinFormPart).GUID], myObject.Parts[typeof(WebFormPart).GUID] };
foreach (TKBObjectPart part in parts){
      if (part.Default.CanCalculateDefault())
       part.Default.SilentSetIsDefault(true);
}
myObject.Save();

...