protected override void OnColumnAdded(DataGridViewColumnEventArgs e)
        {
            if (typeof(TreeGridColumn).IsAssignableFrom(e.Column.GetType()))
            {
                if (_expandableColumn == null)
                {
                    // identify the expanding column.
                    _expandableColumn = (TreeGridColumn)e.Column;
                }
                else
                {
                    // this.Columns.Remove(e.Column);
                    //throw new InvalidOperationException("Only one TreeGridColumn per TreeGridView is supported.");
                }
            }

            // Expandable Grid doesn't support sorting. This is just a limitation of the sample.
            e.Column.SortMode = DataGridViewColumnSortMode.NotSortable;

            base.OnColumnAdded(e);
        }
        /// <summary>
        /// Setup columns ready for showing validation messages
        /// </summary>
        public void SetupForValidationOutput()
        {
            //Set up columns

            //0 (tree grid view seems to not always support accessing by name, so using IDs)
            TreeGridColumn typeLabelColumn = new TreeGridColumn();

            typeLabelColumn.Name       = "TypeLabel";
            typeLabelColumn.HeaderText = "";
            typeLabelColumn.ReadOnly   = true;
            typeLabelColumn.SortMode   = DataGridViewColumnSortMode.NotSortable;
            typeLabelColumn.Width      = 91;
            typeLabelColumn.Resizable  = DataGridViewTriState.False;
            this.Columns.Add(typeLabelColumn);

            //1
            DataGridViewTextBoxColumn messageColumn = new DataGridViewTextBoxColumn();

            messageColumn.Name       = "Message";
            messageColumn.HeaderText = "Message";
            messageColumn.ReadOnly   = true;
            messageColumn.SortMode   = DataGridViewColumnSortMode.NotSortable;
            this.Columns.Add(messageColumn);

            this.DefaultCellStyle.BackColor = Color.White;

            if (this.Width >= 1400)
            {
                messageColumn.Width = this.Width - 100;
            }
            else
            {
                messageColumn.Width = 1300;
            }

            // Will be shown when there are some messages
            this.Visible = false;
        }
        /// <summary>
        /// Setup columns ready for binding to a CubeDiff object
        /// </summary>
        public void SetupForComparison()
        {
            //Set up columns

            //0 (tree grid view seems to no always support accessing by name, so using IDs)
            TreeGridColumn typeLabelColumn = new TreeGridColumn();

            typeLabelColumn.Name       = "TypeLabel";
            typeLabelColumn.HeaderText = "Type";
            typeLabelColumn.ReadOnly   = true;
            typeLabelColumn.SortMode   = DataGridViewColumnSortMode.NotSortable;
            typeLabelColumn.Width      = this.Width / 601 * 161; //hdpi
            this.Columns.Add(typeLabelColumn);

            //1
            DataGridViewTextBoxColumn sourceNameColumn = new DataGridViewTextBoxColumn();

            sourceNameColumn.Name       = "SourceName";
            sourceNameColumn.HeaderText = "Source Name";
            sourceNameColumn.ReadOnly   = true;
            sourceNameColumn.SortMode   = DataGridViewColumnSortMode.NotSortable;
            sourceNameColumn.Width      = this.Width / 601 * 301; //hdpi..
            this.Columns.Add(sourceNameColumn);

            //2
            DataGridViewTextBoxColumn sourceIdColumn = new DataGridViewTextBoxColumn();

            sourceIdColumn.Name       = "SourceID";
            sourceIdColumn.HeaderText = "Source ID";
            sourceIdColumn.ReadOnly   = true;
            sourceIdColumn.Visible    = false;
            sourceIdColumn.SortMode   = DataGridViewColumnSortMode.NotSortable;
            sourceIdColumn.Width      = this.Width / 601 * 200;
            this.Columns.Add(sourceIdColumn);

            //3
            DataGridViewTextBoxColumn equalityColumn = new DataGridViewTextBoxColumn();

            equalityColumn.Name       = "Equality";
            equalityColumn.HeaderText = "";
            equalityColumn.ReadOnly   = true;
            equalityColumn.Visible    = false;
            equalityColumn.SortMode   = DataGridViewColumnSortMode.NotSortable;
            equalityColumn.Width      = this.Width / 601 * 17;
            //equalityColumn.Resizable = DataGridViewTriState.False;
            //equalityColumn.DefaultCellStyle.Font = new Font("Times New Roman", 11);
            this.Columns.Add(equalityColumn);

            //4
            DataGridViewTextBoxColumn statusColumn = new DataGridViewTextBoxColumn();

            statusColumn.Name       = "Status";
            statusColumn.HeaderText = "Status";
            statusColumn.ReadOnly   = true;
            statusColumn.SortMode   = DataGridViewColumnSortMode.NotSortable;
            statusColumn.Width      = this.Width / 601 * 103;
            this.Columns.Add(statusColumn);

            //5
            DataGridViewTextBoxColumn targetNameColumn = new DataGridViewTextBoxColumn();

            targetNameColumn.Name       = "TargetName";
            targetNameColumn.HeaderText = "Target Name";
            targetNameColumn.ReadOnly   = true;
            targetNameColumn.SortMode   = DataGridViewColumnSortMode.NotSortable;
            targetNameColumn.Width      = this.Width / 601 * 301;
            this.Columns.Add(targetNameColumn);

            //6
            DataGridViewTextBoxColumn targetIdColumn = new DataGridViewTextBoxColumn();

            targetIdColumn.Name       = "TargetID";
            targetIdColumn.HeaderText = "Target ID";
            targetIdColumn.ReadOnly   = true;
            targetIdColumn.Visible    = false;
            targetIdColumn.SortMode   = DataGridViewColumnSortMode.NotSortable;
            targetIdColumn.Width      = this.Width / 601 * 200;
            this.Columns.Add(targetIdColumn);

            //7
            DataGridViewImageColumn actionImageColumn = new DataGridViewImageColumn();

            actionImageColumn.Name       = "";
            actionImageColumn.HeaderText = "";
            actionImageColumn.ReadOnly   = true;
            actionImageColumn.Width      = this.Width / 601 * 18;
            actionImageColumn.Resizable  = DataGridViewTriState.False;
            actionImageColumn.SortMode   = DataGridViewColumnSortMode.NotSortable;
            actionImageColumn.Visible    = true;
            this.Columns.Add(actionImageColumn);

            //8
            DataGridViewComboBoxColumn mergeActionColumn = new DataGridViewComboBoxColumn();

            mergeActionColumn.Name             = "MergeAction";
            mergeActionColumn.HeaderText       = "Action";
            mergeActionColumn.MaxDropDownItems = 4;
            mergeActionColumn.FlatStyle        = FlatStyle.Flat;
            mergeActionColumn.SortMode         = DataGridViewColumnSortMode.NotSortable;
            mergeActionColumn.Width            = this.Width / 601 * 83;
            this.Columns.Add(mergeActionColumn);

            //9
            DataGridViewTextBoxColumn typeColumn = new DataGridViewTextBoxColumn();

            typeColumn.Name       = "Type";
            typeColumn.HeaderText = "Type";
            typeColumn.ReadOnly   = true;
            typeColumn.SortMode   = DataGridViewColumnSortMode.NotSortable;
            typeColumn.Visible    = false;
            this.Columns.Add(typeColumn);

            //10
            DataGridViewTextBoxColumn sourceObjDefColumn = new DataGridViewTextBoxColumn();

            sourceObjDefColumn.Name       = "SourceObjDef";
            sourceObjDefColumn.HeaderText = "Source Object Definition";
            sourceObjDefColumn.ReadOnly   = true;
            sourceObjDefColumn.SortMode   = DataGridViewColumnSortMode.NotSortable;
            sourceObjDefColumn.Visible    = false;
            this.Columns.Add(sourceObjDefColumn);

            //11
            DataGridViewTextBoxColumn targetObjDefColumn = new DataGridViewTextBoxColumn();

            targetObjDefColumn.Name       = "TargetObjDef";
            targetObjDefColumn.HeaderText = "Target Object Definition";
            targetObjDefColumn.ReadOnly   = true;
            targetObjDefColumn.SortMode   = DataGridViewColumnSortMode.NotSortable;
            targetObjDefColumn.Visible    = false;
            this.Columns.Add(targetObjDefColumn);

            this.DefaultCellStyle.BackColor = Color.White;
        }