private DialogResult DoDetailsItemOnClick(ColumnInfo cData)
        {
            // Prepare parameters to pass into FieldPropertiesForm
            var cDataClone    = (ColumnInfo)cData.Clone();
            var dataSources   = new DataSources();
            var variablesRepo = RepositoryFactory.Instance.Get <IVariablesRepository>();
            var variables     = variablesRepo.GetAll().ToList();

            foreach (var data in _settings.ColumnDatas)
            {
                if (data.Variable != null && !variables.Contains(data.Variable))
                {
                    variables.Add(data.Variable);
                }
            }
            dataSources.Variables = variables;

            // Show form
            using (var form = new FieldPropertiesForm(cDataClone, dataSources))
            {
                var res = form.ShowDialog();
                if (res != DialogResult.OK)
                {
                    return(res);
                }

                var cDatas = _settings.ColumnDatas;
                var index  = cData.ColumnIndex;
                var cd     = form.ColumnData;

                cDatas[index] = cd;

                // Apply site/variable/source/method/qualityControl to all columns if need
                for (int k = 0; k < cDatas.Count; k++)
                {
                    if (k == index)
                    {
                        continue;
                    }

                    var option = cDatas[k];

                    if (cd.ApplySiteToAllColumns)
                    {
                        option.Site = (Site)cd.Site.Clone();
                    }
                    if (cd.ApplyVariableToAllColumns)
                    {
                        option.Variable = (Variable)cd.Variable.Clone();
                    }
                    if (cd.ApplySourceToAllColumns)
                    {
                        option.Source = (Source)cd.Source.Clone();
                    }
                    if (cd.ApplyMethodToAllColumns)
                    {
                        option.Method = (Method)cd.Method.Clone();
                    }
                    if (cd.ApplyQualityControlToAllColumns)
                    {
                        option.QualityControlLevel = (QualityControlLevel)cd.QualityControlLevel.Clone();
                    }
                    if (cd.ApplyOffsetToAllColumns)
                    {
                        option.OffsetType  = (OffsetType)cd.OffsetType.Clone();
                        option.OffsetValue = cd.OffsetValue;
                    }
                }

                columnsToImportControl1.RefreshData();
                return(res);
            }
        }
        /// <summary>
        /// Create new instance of <see cref="FieldPropertiesForm"/>
        /// </summary>
        /// <param name="columnData">Column data</param>
        /// <param name="dataSources">Data sources for comboboxes, etc...</param>
        public FieldPropertiesForm(ColumnInfo columnData, DataSources dataSources)
        {
            if (columnData == null)
            {
                throw new ArgumentNullException("columnData");
            }
            if (dataSources == null)
            {
                throw new ArgumentNullException("dataSources");
            }
            Contract.EndContractBlock();

            _columnData = columnData;
            InitializeComponent();

            if (this.IsDesignMode())
            {
                return;
            }

            base.Text = string.Format("Column properties - {0}", _columnData.ColumnName);

            // Set bindings.......
            chApplySiteToAllCoumns.AddBinding(c => c.Checked, _columnData, c => c.ApplySiteToAllColumns);
            chApplyVariableToAllColumns.AddBinding(c => c.Checked, _columnData, c => c.ApplyVariableToAllColumns);
            chApplySourceToAllColumns.AddBinding(c => c.Checked, _columnData, c => c.ApplySourceToAllColumns);
            chApplyMethodToAllColumns.AddBinding(c => c.Checked, _columnData, c => c.ApplyMethodToAllColumns);
            chApplyQualityControlToAllColumns.AddBinding(c => c.Checked, _columnData, c => c.ApplyQualityControlToAllColumns);
            chApplyOffsetToAllColumns.AddBinding(c => c.Checked, _columnData, c => c.ApplyOffsetToAllColumns);

            // Site
            siteView1.ReadOnly             = true;
            cmbSites.SelectedIndexChanged += CmbSitesOnSelectedIndexChanged;
            var sitesRepo = RepositoryFactory.Instance.Get <ISitesRepository>();
            var sites     = sitesRepo.GetAll();

            if (_columnData.Site != null &&
                !sites.Contains(_columnData.Site))
            {
                sites.Add(_columnData.Site);
            }
            sitesBindingSource.DataSource = sites;
            cmbSites.DataSource           = sitesBindingSource;
            cmbSites.DisplayMember        = NameHelper <Site> .Name(s => s.Name);

            if (_columnData.Site != null)
            {
                cmbSites.SelectedItem = _columnData.Site;
            }

            // Variable
            variableView1.ReadOnly             = true;
            cmbVariables.SelectedIndexChanged += CmbVariablesOnSelectedIndexChanged;
            variablesBindingSource.DataSource  = dataSources.Variables;
            cmbVariables.DataSource            = variablesBindingSource;
            cmbVariables.DisplayMember         = NameHelper <Variable> .Name(s => s.Name);

            if (_columnData.Variable != null)
            {
                cmbVariables.SelectedItem = _columnData.Variable;
            }

            // Source
            sourceView1.Entity = _columnData.Source;

            // Method
            methodView1.Entity = _columnData.Method;

            // Quality Control
            qualityControlLevelView1.Entity = _columnData.QualityControlLevel;

            // Offset
            offsetTypeView1.Entity = _columnData.OffsetType;
            nudOffsetValue.AddBinding <NumericUpDown, ColumnInfo>(x => x.Value, _columnData, c => c.OffsetValue);
        }