private void buttonProperties_Click(object sender, EventArgs e)
 {
     if (olvSelectedFields.SelectedObject != null)
     {
         IField selectedField = (IField)olvSelectedFields.SelectedObject;
         if (selectedField is Field)
         {
             if (((Field)selectedField).FieldType is StringFieldType)
             {
                 StringFieldPropertiesForm frm = new StringFieldPropertiesForm {
                     StringFieldType = ((Field)selectedField).FieldType as StringFieldType
                 };
                 if (frm.ShowDialog() == DialogResult.OK)
                 {
                     ((Field)selectedField).FieldType = frm.StringFieldType;
                 }
             }
             else if (((Field)selectedField).FieldType is DateFieldType)
             {
                 DateFieldPropertiesForm frm = new DateFieldPropertiesForm {
                     DateFieldType = ((Field)selectedField).FieldType as DateFieldType
                 };
                 if (frm.ShowDialog() == DialogResult.OK)
                 {
                     ((Field)selectedField).FieldType = frm.DateFieldType;
                 }
             }
             else if (((Field)selectedField).FieldType is DecimalFieldType)
             {
                 DecimalFieldPropertiesForm frm = new DecimalFieldPropertiesForm {
                     DecimalFieldType = ((Field)selectedField).FieldType as DecimalFieldType
                 };
                 if (frm.ShowDialog() == DialogResult.OK)
                 {
                     ((Field)selectedField).FieldType = frm.DecimalFieldType;
                 }
             }
             else if (((Field)selectedField).FieldType is IntegerFieldType)
             {
                 IntegerFieldPropertiesForm frm = new IntegerFieldPropertiesForm {
                     IntegerFieldType = ((Field)selectedField).FieldType as IntegerFieldType
                 };
                 if (frm.ShowDialog() == DialogResult.OK)
                 {
                     ((Field)selectedField).FieldType = frm.IntegerFieldType;
                 }
             }
         }
         else if (selectedField is ComplexField)
         {
             ComplexFieldPropertiesForm frm = new ComplexFieldPropertiesForm
             {
                 DefaultFields     = _defaultList,
                 ComplexField      = selectedField as ComplexField,
                 UseSpecificLength = _useSpecficLenght,
                 ExportMode        = this.ExportMode
             };
             if (frm.ShowDialog() == DialogResult.OK)
             {
                 ((ComplexField)olvSelectedFields.SelectedObject).DisplayName = frm.ComplexField.DisplayName;
                 ((ComplexField)olvSelectedFields.SelectedObject).Name        = frm.ComplexField.Name;
                 ((ComplexField)olvSelectedFields.SelectedObject).Fields      = frm.ComplexField.Fields;
                 ((ComplexField)olvSelectedFields.SelectedObject).Length      = frm.ComplexField.Length;
                 olvSelectedFields.RefreshObject(olvSelectedFields.SelectedObject);
             }
         }
     }
 }
 private void buttonProperties_Click(object sender, EventArgs e)
 {
     if (olvSelectedFields.SelectedObject != null)
     {
         IField selectedField = (IField)olvSelectedFields.SelectedObject;
         if (selectedField is Field)
         {
             if (((Field)selectedField).FieldType is StringFieldType)
             {
                 StringFieldPropertiesForm frm = new StringFieldPropertiesForm { StringFieldType = ((Field)selectedField).FieldType as StringFieldType };
                 if (frm.ShowDialog() == DialogResult.OK)
                     ((Field)selectedField).FieldType = frm.StringFieldType;
             }
             else if (((Field)selectedField).FieldType is DateFieldType)
             {
                 DateFieldPropertiesForm frm = new DateFieldPropertiesForm { DateFieldType = ((Field)selectedField).FieldType as DateFieldType };
                 if (frm.ShowDialog() == DialogResult.OK)
                     ((Field)selectedField).FieldType = frm.DateFieldType;
             }
             else if (((Field)selectedField).FieldType is DecimalFieldType)
             {
                 DecimalFieldPropertiesForm frm = new DecimalFieldPropertiesForm { DecimalFieldType = ((Field)selectedField).FieldType as DecimalFieldType };
                 if (frm.ShowDialog() == DialogResult.OK)
                     ((Field)selectedField).FieldType = frm.DecimalFieldType;
             }
             else if (((Field)selectedField).FieldType is IntegerFieldType)
             {
                 IntegerFieldPropertiesForm frm = new IntegerFieldPropertiesForm { IntegerFieldType = ((Field)selectedField).FieldType as IntegerFieldType };
                 if (frm.ShowDialog() == DialogResult.OK)
                     ((Field)selectedField).FieldType = frm.IntegerFieldType;
             }
         }
         else if (selectedField is ComplexField)
         {
             ComplexFieldPropertiesForm frm = new ComplexFieldPropertiesForm
             {
                 DefaultFields = _defaultList,
                 ComplexField = selectedField as ComplexField,
                 UseSpecificLength = _useSpecficLenght,
                 ExportMode = this.ExportMode
             };
             if (frm.ShowDialog() == DialogResult.OK)
             {
                ((ComplexField)olvSelectedFields.SelectedObject).DisplayName = frm.ComplexField.DisplayName;
                ((ComplexField)olvSelectedFields.SelectedObject).Name = frm.ComplexField.Name;
                ((ComplexField)olvSelectedFields.SelectedObject).Fields = frm.ComplexField.Fields;
                ((ComplexField)olvSelectedFields.SelectedObject).Length = frm.ComplexField.Length;
                 olvSelectedFields.RefreshObject(olvSelectedFields.SelectedObject);
             }
         }
         else if (selectedField is CustomField)
         {
             CustomFieldPropertiesForm frm = new CustomFieldPropertiesForm { CustomField = selectedField as CustomField };
             if (frm.ShowDialog() == DialogResult.OK)
             {
                 var customField = frm.CustomField;
                 olvSelectedFields.RefreshObject(customField);
             }
         }
     }
 }