# Autogenerated Complex objects

## Overview

A complex object is a property that consists of other simple properties or complex objects. Sitefinity CMS automatically generates editors for the them, depending on their types.

## Complex object

The following screenshot displays a complex object with two properties of types `string` and `int`:

![complex-object](https://www.progress.com/documentation/sitefinity-cms/assets/4affc8c2dc9eef1d7479c924f31ca4d8/complex-object.png "complex-object")

## Nested complex objects

The following screenshot displays a complex object that has one property and another complex object, which in turn, has two properties:

![multilevel-complex-object](https://www.progress.com/documentation/sitefinity-cms/assets/8889fb0db192395f6662f5bc3087dff5/multilevel-complex-object.png "multilevel-complex-object")

## Table with complex objects

You can have a custom widget that displays multiple complex objects in a table view with the ability to add or remove more entries such as the following:
![ComplexObjectsTable](https://www.progress.com/documentation/sitefinity-cms/assets/d9e35ca5d30449cc179eb80b6895a837/complexobjectstable.png "ComplexObjectsTable") 
In the screenshot above every row from the table displays the properties of one complex object. You can achieve this by using the `TableView` attribute.\
For more information see [Customize autogenerated fields](https://www.progress.com/documentation/sitefinity-cms/customize-autogenerated-fields) » *TableView*.

### Display all properties

In cases when you have a lot of properties that cannot be displayed on one row, Sitefinity displays only the first 5 properties, you can edit the rest of the properties, by clicking ![Edit](https://www.progress.com/documentation/sitefinity-cms/assets/8afd240d47ce5e27c5d697a63f962b8d/edit.png "Edit") (*Edit*) in column *MORE DETAILS*. This will expand all the properties of the complex object in a new page.

You can control the number of columns displayed, using the TableView property.\
For more information, see [Customize autogenerated fields](https://www.progress.com/documentation/sitefinity-cms/customize-autogenerated-fields) » *TableView*.

### Display a nested complex object

If there is a complex object inside a complex object, you can edit its properties, by clicking ![Edit](https://www.progress.com/documentation/sitefinity-cms/assets/8afd240d47ce5e27c5d697a63f962b8d/edit.png "Edit") (*Edit*) in column *INNER COMPLEX OBJECT*. In case the inner complex object is in the detailed page of properties, there is a section *Inner complex object* that you can expand and view the properties.

## Code sample

To insert a complex object, use the following code sample:

```C#
using System.ComponentModel;
using Progress.Sitefinity.Renderer.Entities.Content;
using Progress.Sitefinity.Renderer.Designers.Attributes;

namespace SitefinityWebApp
{
   public class DemoComplexObjects
   {
     public ComplexObject Complex { get; set; }

     public MultiLevelComplexObject MultiLevelComplexObject { get; set; }

     public IList<string> List { get; set; }

     public IList<ComplexObject> ListComplexObject { get; set; }

     public IList<ComplexObjectNoDefaults> ListComplexObjectNoDefaults { get; set; }
   }
   
   public class ComplexObject
   {
     [DisplayName("String prop")]
     [DefaultValue("test")]
     public string ChildString { get; set; }

     [DisplayName("Int prop")]
     [DefaultValue(42)]
     public int ChildInt { get; set; }
   }

   public class ComplexObjectNoDefaults
   {
     [DisplayName("Boolean prop")]
     public bool BoolProp { get; set; }

     [DisplayName("Int prop")]
     public int ChildInt { get; set; }
     }

   public class MultiLevelComplexObject
   {
     [DisplayName("String prop")]
     [DefaultValue("testouter")]
     public string ChildString { get; set; }

     [DisplayName("Child complex prop")]
     public ComplexObject ChildComplexObject { get; set; }
   }   
}
```
