private void initializeOtherTypeObjectOfArrayCell(int rowIndex, int arrayIndex)
        {
            //initializeOtherObjectTypeCell(rowIndex, String.Format("[{0}]", arrayIndex), ref value);
            // TODO
            object[] array = (object[])_editedObject;
            var      value = array[arrayIndex];

            if (value is bool)
            {
                this[1, rowIndex] = new DataGridViewCheckBoxCell(false);
                ((DataGridViewCheckBoxCell)this[1, rowIndex]).Value = value;

                /*this.CellContentClick +=
                 *  (sender, e) =>
                 *  {
                 *      if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 && _editingCells[rowIndex])
                 *      {
                 *          if (!_previouslyReloadedValue)
                 *          {
                 *              array[arrayIndex] = this[1, e.RowIndex].Value;
                 *              this[0, e.RowIndex].Selected = true;
                 *              _editingCells[rowIndex] = !(AnythingChanged = true);
                 *          }
                 *          else _previouslyReloadedValue = false;
                 *      }
                 *  };*/
                // Defocus after click - then the CellValueChanged event will be thrown
                this.CellContentClick +=
                    (sender, e) =>
                {
                    if (e.RowIndex >= 0)
                    {
                        if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 && _editingCells[rowIndex])
                        {
                            _previouslyReloadedValue     = false;
                            this[0, e.RowIndex].Selected = true;
                        }
                    }
                };

                this.CellValueChanged +=
                    (sender, e) =>
                {
                    if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 && _editingCells[rowIndex])
                    {
                        if (!_previouslyReloadedValue)
                        {
                            try
                            {
                                array[arrayIndex] = this[1, e.RowIndex].Value;
                            }
                            catch
                            {
                                showPropertyUnableToBeSetMessage("[" + arrayIndex + "]");
                            }

                            _editingCells[rowIndex] = !(AnythingChanged = true);
                        }
                    }
                };
            }
            else if (value is Color)
            {
                this[1, rowIndex]       = new DataGridViewButtonCell();
                this[1, rowIndex].Value = value;
                ((DataGridViewButtonCell)this[1, rowIndex]).Style.BackColor = (Color)value;

                this.CellContentClick +=
                    (sender, e) =>
                {
                    if (e.RowIndex >= 0)
                    {
                        if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 /*&& _editingCells[rowIndex]*/)
                        {
                            ColorDialog  colDialog = new ColorDialog();
                            DialogResult result    = colDialog.ShowDialog();

                            if (result == DialogResult.OK)
                            {
                                array[arrayIndex]       = colDialog.Color;
                                this[1, rowIndex].Value = colDialog.Color;
                                ((DataGridViewButtonCell)this[1, e.RowIndex]).Style.BackColor = colDialog.Color;
                                _editingCells[rowIndex] = !(AnythingChanged = true);
                            }
                            // TODO zjistit jiné výsledky dialogResult
                        }
                    }
                };
            }
            else if (value is SolidBrush)
            {
                this[1, rowIndex]       = new DataGridViewButtonCell();
                this[1, rowIndex].Value = ((SolidBrush)value).Color;
                ((DataGridViewButtonCell)this[1, rowIndex]).FlatStyle       = FlatStyle.Popup;
                ((DataGridViewButtonCell)this[1, rowIndex]).Style.BackColor = ((SolidBrush)value).Color;

                this.CellContentClick +=
                    (sender, e) =>
                {
                    if (e.RowIndex >= 0)
                    {
                        if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 /*&& _editingCells[rowIndex]*/)
                        {
                            ColorDialog  colDialog = new ColorDialog();
                            DialogResult result    = colDialog.ShowDialog();

                            if (result == DialogResult.OK)
                            {
                                SolidBrush proprt = (SolidBrush)array[arrayIndex];
                                proprt.Color            = colDialog.Color;
                                array[arrayIndex]       = proprt;
                                this[1, rowIndex].Value = colDialog.Color;
                                ((DataGridViewButtonCell)this[1, e.RowIndex]).Style.BackColor = colDialog.Color;
                                _editingCells[rowIndex] = !(AnythingChanged = true);
                            }
                            // TODO zjistit jiné výsledky dialogResult
                        }
                    }
                };
            }
            else if (value is Pen)
            {
                this[1, rowIndex]       = new DataGridViewButtonCell();
                this[1, rowIndex].Value = ((Pen)value).Width;
                ((DataGridViewButtonCell)this[1, rowIndex]).FlatStyle       = FlatStyle.Popup;
                ((DataGridViewButtonCell)this[1, rowIndex]).Style.BackColor = ((Pen)value).Color;

                PropertyInfo[] propsToDisplay = new PropertyInfo[2]
                {
                    typeof(Pen).GetProperty("Brush"),
                    typeof(Pen).GetProperty("Width")
                };

                this.CellContentClick +=
                    (sender, e) =>
                {
                    if (e.RowIndex >= 0)
                    {
                        if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 /*&& _editingCells[rowIndex]*/)
                        {
                            object prop = array[arrayIndex];
                            PropertiesEditFlyOut flyout = (PropertiesEditFlyOut)Activator.CreateInstance(typeof(PropertiesEditFlyOut), prop, propsToDisplay, ((DataGridViewTextBoxCell)this[0, rowIndex]).Value);
                            //propertiesFlyOuts.Add(rowIndex, (PropertiesEditFlyOut)Activator.CreateInstance(typeof(PropertiesEditFlyOut), prop, propsToDisplay));
                            //propertiesFlyOuts[rowIndex].Name = String.Format("PropertiesEditFlyOut-{0}-{1}", this.Name, rowIndex);

                            flyout.EditingFinished +=
                                (result, editedObjectChanged, editedObject) =>
                            {
                                if (result != DialogResult.Cancel && editedObjectChanged)
                                {
                                    array[arrayIndex] = editedObject;
                                    ((DataGridViewButtonCell)this[1, e.RowIndex]).Style.BackColor = ((Pen)editedObject).Color;
                                    ((DataGridViewButtonCell)this[1, e.RowIndex]).Value           = ((Pen)editedObject).Width;
                                    _editingCells[rowIndex] = !(AnythingChanged = true);
                                }
                                // TODO zjistit jiné výsledky dialogResult
                                flyout.Dispose();
                            };

                            flyout.Show();
                        }
                    }
                };
            }
            else if (value is DateTime)
            {
                //this[1, rowIndex].ValueType = typeof(DateTime);
                this[1, rowIndex].Value = value;

                this.CellEndEdit +=
                    (sender, e) =>
                {
                    if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 && _editingCells[rowIndex])
                    {
                        array[arrayIndex]       = DateTime.Parse(this[1, rowIndex].Value.ToString());
                        _editingCells[rowIndex] = !(AnythingChanged = true);
                    }
                };
            }
            else if (value is TimeSpan)
            {
                //this[1, rowIndex].ValueType = typeof(DateTime);
                this[1, rowIndex].Value = value;

                this.CellEndEdit +=
                    (sender, e) =>
                {
                    if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 && _editingCells[rowIndex])
                    {
                        array[arrayIndex]       = TimeSpan.Parse(this[1, rowIndex].Value.ToString());
                        _editingCells[rowIndex] = !(AnythingChanged = true);
                    }
                };
            }
            else if (value is Point)
            {
                this[1, rowIndex].Value = value;

                this.CellEndEdit +=
                    (sender, e) =>
                {
                    if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 && _editingCells[rowIndex])
                    {
                        array[arrayIndex]       = this[1, rowIndex].Value;
                        _editingCells[rowIndex] = !(AnythingChanged = true);
                    }
                };
            }
            else if (value is PointF)
            {
                this[1, rowIndex].Value = value;

                this.CellEndEdit +=
                    (sender, e) =>
                {
                    if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 && _editingCells[rowIndex])
                    {
                        array[arrayIndex]       = this[1, rowIndex].Value;
                        _editingCells[rowIndex] = !(AnythingChanged = true);
                    }
                };
            }
            else
            {
                Type type = value.GetType();
                if (type.IsEnum)
                {
                    this[1, rowIndex] = new DataGridViewComboBoxCell();
                    ((DataGridViewComboBoxCell)this[1, rowIndex]).Items.AddRange(type.GetEnumNames());
                    ((DataGridViewComboBoxCell)this[1, rowIndex]).Value = value.ToString();

                    this.CellValueChanged +=
                        (sender, e) =>
                    {
                        if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 && _editingCells[rowIndex])
                        {
                            array[arrayIndex]       = Enum.Parse(type, this[1, e.RowIndex].Value.ToString());
                            _editingCells[rowIndex] = !(AnythingChanged = true);
                        }
                    };
                }
                else if (type.BaseType == typeof(UserControl) || type.BaseType.Name.Contains("UserControl"))
                {
                    PropertyInfo[] props = type.GetProperties().FilterPropertiesBasedOnOtherTypes(new Type[1] {
                        typeof(UserControl)
                    }, false);
                    if (type.ImplementsInterface(typeof(AlgoNature.Components.IBitmapGraphicChild)))
                    {
                        props = props.FilterPropertiesBasedOnOtherTypes(new Type[1] {
                            typeof(AlgoNature.Components.IBitmapGraphicChild)
                        }, false);
                    }

                    this[1, rowIndex] = new DataGridViewButtonCell();
                    ((DataGridViewButtonCell)this[1, rowIndex]).Value = value;

                    this.CellContentClick +=
                        (sender, e) =>
                    {
                        if (e.RowIndex >= 0)
                        {
                            if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 /*&& _editingCells[rowIndex]*/)
                            {
                                object prop = array[arrayIndex];

                                PropertiesEditFlyOut flyout = (PropertiesEditFlyOut)Activator.CreateInstance(typeof(PropertiesEditFlyOut), prop, props, ((DataGridViewTextBoxCell)this[0, rowIndex]).Value);

                                flyout.EditingFinished +=
                                    (result, editedObjectChanged, editedObject) =>
                                {
                                    if (result != DialogResult.Cancel && editedObjectChanged)
                                    {
                                        array[arrayIndex]       = editedObject;
                                        _editingCells[rowIndex] = !(AnythingChanged = true);
                                    }
                                    // TODO zjistit jiné výsledky dialogResult
                                    flyout.Dispose();
                                };

                                flyout.Show();
                            }
                        }
                    };
                }
                else
                {
                    this[1, rowIndex] = new DataGridViewButtonCell();
                    ((DataGridViewButtonCell)this[1, rowIndex]).Value = value;

                    this.CellContentClick +=
                        (sender, e) =>
                    {
                        if (e.RowIndex >= 0)
                        {
                            if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 /*&& _editingCells[rowIndex]*/)
                            {
                                object prop = array[arrayIndex];
                                PropertiesEditFlyOut flyout = (PropertiesEditFlyOut)Activator.CreateInstance(typeof(PropertiesEditFlyOut), prop, ((DataGridViewTextBoxCell)this[0, rowIndex]).Value);
                                //propertiesFlyOuts.Add(rowIndex, (PropertiesEditFlyOut)Activator.CreateInstance(typeof(PropertiesEditFlyOut), prop));

                                flyout.EditingFinished +=
                                    (result, editedObjectChanged, editedObject) =>
                                {
                                    if (result != DialogResult.Cancel && editedObjectChanged)
                                    {
                                        array[arrayIndex]       = editedObject;
                                        _editingCells[rowIndex] = !(AnythingChanged = true);
                                    }
                                    // TODO zjistit jiné výsledky dialogResult
                                    flyout.Dispose();
                                };

                                flyout.Show();
                            }
                        }
                    };
                }
            }
        }
        private void initializeOtherObjectTypePropertyCell(int rowIndex, int propertiesIndex)
        {
            var value = _properties[propertiesIndex].GetValue(_editedObject);

            /*if (!value.GetType().IsValueType)
             * {
             *  try
             *  {
             *      MethodInfo method = value.GetType().GetMethod("Clone");
             *      value = method.Invoke(value, new object[0]);
             *  }
             *  catch
             *  {
             *      value = value.CloneObject();
             *  }
             * }*/

            if (_properties[propertiesIndex].SetMethod?.IsPublic != true)
            {
                this[1, rowIndex].ReadOnly        = true; // Don't allow changing the property if it is readonly
                this[0, rowIndex].Style.ForeColor = Color.Gray;
                this[1, rowIndex].Style.ForeColor = Color.Gray;
            }


            if (value is bool)
            {
                this[1, rowIndex] = new DataGridViewCheckBoxCell(false);
                ((DataGridViewCheckBoxCell)this[1, rowIndex]).Value = value;

                // Defocus after click - then the CellValueChanged event will be thrown
                this.CellContentClick +=
                    (sender, e) =>
                {
                    if (e.RowIndex >= 0)
                    {
                        if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 && _editingCells[rowIndex])
                        {
                            _previouslyReloadedValue     = false;
                            this[0, e.RowIndex].Selected = true;
                        }
                    }
                };

                this.CellValueChanged +=
                    (sender, e) =>
                {
                    if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 && _editingCells[rowIndex])
                    {
                        if (!_previouslyReloadedValue)
                        {
                            try
                            {
                                _properties[rowIndex].SetValue(_editedObject, this[1, e.RowIndex].Value);
                            }
                            catch
                            {
                                if (_editedObject is Pen)
                                {
                                    _editedObject = new Pen(((Pen)_editedObject).Color, (float)this[1, e.RowIndex].Value);
                                }
                                else
                                {
                                    showPropertyUnableToBeSetMessage(_properties[rowIndex].Name);
                                }
                            }

                            _editingCells[rowIndex] = !(AnythingChanged = true);
                        }
                    }
                };
            }
            else if (value is Color)
            {
                this[1, rowIndex]       = new DataGridViewButtonCell();
                this[1, rowIndex].Value = value;
                ((DataGridViewButtonCell)this[1, rowIndex]).FlatStyle       = FlatStyle.Popup;
                ((DataGridViewButtonCell)this[1, rowIndex]).Style.BackColor = (Color)value;

                this.CellContentClick +=
                    (sender, e) =>
                {
                    if (e.RowIndex >= 0)
                    {
                        if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 /*&& _editingCells[rowIndex]*/)
                        {
                            ColorDialog  colDialog = new ColorDialog();
                            DialogResult result    = colDialog.ShowDialog();

                            if (result == DialogResult.OK)
                            {
                                _properties[propertiesIndex].SetValue(_editedObject, colDialog.Color);
                                this[1, rowIndex].Value = colDialog.Color;
                                ((DataGridViewButtonCell)this[1, e.RowIndex]).Style.BackColor = colDialog.Color;
                                _editingCells[rowIndex] = !(AnythingChanged = true);
                            }
                            // TODO zjistit jiné výsledky dialogResult
                        }
                    }
                };
            }
            else if (value is SolidBrush)
            {
                this[1, rowIndex]       = new DataGridViewButtonCell();
                this[1, rowIndex].Value = ((SolidBrush)value).Color;
                ((DataGridViewButtonCell)this[1, rowIndex]).FlatStyle       = FlatStyle.Popup;
                ((DataGridViewButtonCell)this[1, rowIndex]).Style.BackColor = ((SolidBrush)value).Color;

                this.CellContentClick +=
                    (sender, e) =>
                {
                    if (e.RowIndex >= 0)
                    {
                        if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 /*&& _editingCells[rowIndex]*/)
                        {
                            ColorDialog  colDialog = new ColorDialog();
                            DialogResult result    = colDialog.ShowDialog();

                            if (result == DialogResult.OK)
                            {
                                SolidBrush proprt = (SolidBrush)_properties[propertiesIndex].GetValue(_editedObject);
                                proprt.Color = colDialog.Color;
                                try
                                {
                                    _properties[propertiesIndex].SetValue(_editedObject, proprt);
                                }
                                catch
                                {
                                    if (_editedObject is Pen)
                                    {
                                        _editedObject = new Pen(proprt, ((Pen)_editedObject).Width);
                                    }
                                    else
                                    {
                                        showPropertyUnableToBeSetMessage(_properties[propertiesIndex].Name);
                                    }
                                }

                                this[1, rowIndex].Value = colDialog.Color;
                                ((DataGridViewButtonCell)this[1, e.RowIndex]).Style.BackColor = colDialog.Color;
                                _editingCells[rowIndex] = !(AnythingChanged = true);
                            }
                            // TODO zjistit jiné výsledky dialogResult
                        }
                    }
                };
            }
            else if (value is Pen)
            {
                this[1, rowIndex]       = new DataGridViewButtonCell();
                this[1, rowIndex].Value = ((Pen)value).Width;
                ((DataGridViewButtonCell)this[1, rowIndex]).FlatStyle       = FlatStyle.Popup;
                ((DataGridViewButtonCell)this[1, rowIndex]).Style.BackColor = ((Pen)value).Color;

                PropertyInfo[] propsToDisplay = new PropertyInfo[2]
                {
                    typeof(Pen).GetProperty("Brush"),
                    typeof(Pen).GetProperty("Width")
                };

                this.CellContentClick +=
                    (sender, e) =>
                {
                    if (e.RowIndex >= 0)
                    {
                        if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 /*&& _editingCells[rowIndex]*/)
                        {
                            /*ColorDialog colDialog = new ColorDialog();
                             * DialogResult result = colDialog.ShowDialog();
                             *
                             * if (result == DialogResult.OK)
                             * {
                             *  Pen proprt = (Pen)_properties[propertiesIndex].GetValue(_editedObject);
                             *  proprt = (Pen)proprt.Clone();
                             *  proprt.Color = colDialog.Color;
                             *  try
                             *  {
                             *      _properties[propertiesIndex].SetValue(_editedObject, proprt);
                             *  }
                             *  catch
                             *  {
                             *      showPropertyUnableToBeSetMessage(_properties[propertiesIndex].Name);
                             *  }
                             *
                             *  this[1, rowIndex].Value = colDialog.Color;
                             *  ((DataGridViewButtonCell)this[1, e.RowIndex]).Style.BackColor = colDialog.Color;
                             *  _editingCells[rowIndex] = !(AnythingChanged = true);
                             * }*/
                            object prop = _properties[propertiesIndex].GetValue(_editedObject);
                            PropertiesEditFlyOut flyout = (PropertiesEditFlyOut)Activator.CreateInstance(typeof(PropertiesEditFlyOut), prop, propsToDisplay, ((DataGridViewTextBoxCell)this[0, rowIndex]).Value);
                            //propertiesFlyOuts[rowIndex].Name = String.Format("PropertiesEditFlyOut-{0}-{1}", this.Name, rowIndex);

                            flyout.EditingFinished +=
                                (result, editedObjectChanged, editedObject) =>
                            {
                                if (result != DialogResult.Cancel && editedObjectChanged)
                                {
                                    _properties[propertiesIndex].SetValue(_editedObject, editedObject);
                                    ((DataGridViewButtonCell)this[1, e.RowIndex]).Style.BackColor = ((Pen)editedObject).Color;
                                    ((DataGridViewButtonCell)this[1, e.RowIndex]).Value           = ((Pen)editedObject).Width;
                                    _editingCells[rowIndex] = !(AnythingChanged = true);
                                }
                                // TODO zjistit jiné výsledky dialogResult
                                flyout.Dispose();
                            };

                            flyout.Show();
                        }
                    }
                };
            }
            else if (value is DateTime)
            {
                //this[1, rowIndex].ValueType = typeof(DateTime);
                this[1, rowIndex].Value = value;

                this.CellEndEdit +=
                    (sender, e) =>
                {
                    if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 && _editingCells[rowIndex])
                    {
                        _properties[propertiesIndex].SetValue(_editedObject, DateTime.Parse(this[1, rowIndex].Value.ToString()));
                        _editingCells[rowIndex] = !(AnythingChanged = true);
                    }
                };
            }
            else if (value is TimeSpan)
            {
                //this[1, rowIndex].ValueType = typeof(DateTime);
                this[1, rowIndex].Value = value;

                this.CellEndEdit +=
                    (sender, e) =>
                {
                    if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 && _editingCells[rowIndex])
                    {
                        _properties[propertiesIndex].SetValue(_editedObject, TimeSpan.Parse(this[1, rowIndex].Value.ToString()));
                        _editingCells[rowIndex] = !(AnythingChanged = true);
                    }
                };
            }
            else if (value is Point)
            {
                this[1, rowIndex].Value = value;

                this.CellEndEdit +=
                    (sender, e) =>
                {
                    if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 && _editingCells[rowIndex])
                    {
                        _properties[propertiesIndex].SetValue(_editedObject, ((string)this[1, rowIndex].Value).ToPoint());
                        _editingCells[rowIndex] = !(AnythingChanged = true);
                    }
                };
            }
            else if (value is PointF)
            {
                this[1, rowIndex].Value = value;

                this.CellEndEdit +=
                    (sender, e) =>
                {
                    if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 && _editingCells[rowIndex])
                    {
                        _properties[propertiesIndex].SetValue(_editedObject, ((string)this[1, rowIndex].Value).ToPointF());
                        _editingCells[rowIndex] = !(AnythingChanged = true);
                    }
                };
            }
            else
            {
                Type type = value.GetType();
                if (type.IsEnum)
                {
                    this[1, rowIndex] = new DataGridViewComboBoxCell();
                    ((DataGridViewComboBoxCell)this[1, rowIndex]).Items.AddRange(type.GetEnumNames());
                    ((DataGridViewComboBoxCell)this[1, rowIndex]).Value = value.ToString();

                    this.CellValueChanged +=
                        (sender, e) =>
                    {
                        if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 && _editingCells[rowIndex])
                        {
                            _properties[propertiesIndex].SetValue(_editedObject, Enum.Parse(type, this[1, e.RowIndex].Value.ToString()));
                            //this[0, e.RowIndex].Selected = true;
                            _editingCells[rowIndex] = !(AnythingChanged = true);
                        }
                    };
                }
                else if (type.BaseType == typeof(UserControl) || type.BaseType.Name.Contains("UserControl"))
                {
                    PropertyInfo[] props = type.GetProperties().FilterPropertiesBasedOnOtherTypes(new Type[1] {
                        typeof(UserControl)
                    }, false);
                    if (type.ImplementsInterface(typeof(AlgoNature.Components.IBitmapGraphicChild)))
                    {
                        props = props.FilterPropertiesBasedOnOtherTypes(new Type[1] {
                            typeof(AlgoNature.Components.IBitmapGraphicChild)
                        }, false);
                    }

                    this[1, rowIndex] = new DataGridViewButtonCell();
                    ((DataGridViewButtonCell)this[1, rowIndex]).Value = value;

                    this.CellContentClick +=
                        (sender, e) =>
                    {
                        if (e.RowIndex >= 0)
                        {
                            if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 /*&& _editingCells[rowIndex]*/)
                            {
                                object prop = _properties[propertiesIndex].GetValue(_editedObject);

                                PropertiesEditFlyOut flyout = (PropertiesEditFlyOut)Activator.CreateInstance(typeof(PropertiesEditFlyOut), prop, props, ((DataGridViewTextBoxCell)this[0, rowIndex]).Value);

                                flyout.EditingFinished +=
                                    (result, editedObjectChanged, editedObject) =>
                                {
                                    if (result != DialogResult.Cancel && editedObjectChanged)
                                    {
                                        _properties[propertiesIndex].SetValue(_editedObject, editedObject);
                                        _editingCells[rowIndex] = !(AnythingChanged = true);
                                    }
                                    // TODO zjistit jiné výsledky dialogResult
                                    flyout.Dispose();
                                };

                                flyout.Show();
                            }
                        }
                    };
                }
                else
                {
                    this[1, rowIndex] = new DataGridViewButtonCell();
                    ((DataGridViewButtonCell)this[1, rowIndex]).Value = value;

                    this.CellContentClick +=
                        (sender, e) =>
                    {
                        if (e.RowIndex >= 0)
                        {
                            if (Convert.ToInt32(((DataGridViewTextBoxCell)this[2, e.RowIndex]).Value) == rowIndex && e.ColumnIndex != 0 /*&& _editingCells[rowIndex]*/)
                            {
                                object prop = _properties[propertiesIndex].GetValue(_editedObject);

                                PropertiesEditFlyOut flyout = (PropertiesEditFlyOut)Activator.CreateInstance(typeof(PropertiesEditFlyOut), prop, ((DataGridViewTextBoxCell)this[0, rowIndex]).Value);

                                flyout.EditingFinished +=
                                    (result, editedObjectChanged, editedObject) =>
                                {
                                    if (result != DialogResult.Cancel && editedObjectChanged)
                                    {
                                        _properties[propertiesIndex].SetValue(_editedObject, editedObject);
                                        _editingCells[rowIndex] = !(AnythingChanged = true);
                                    }
                                    // TODO zjistit jiné výsledky dialogResult
                                    flyout.Dispose();
                                };

                                flyout.Show();
                            }
                        }
                    };
                }
            }
        }