Ejemplo n.º 1
0
        private void SetPropertyInfo(object value)
        {
            PropertyInfo[] pinf = this.prop.SelectedObject.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
            foreach (PropertyInfo item in pinf)
            {
                object UpdateObjectValue      = null;
                string ValueForObjectInString = "";
                if (Enum.IsDefined(typeof(ValueChanged), item.Name) && item.Name.Equals(valueChanged.ToString()))
                {
                    switch (item.Name)
                    {
                    default:
                    {
                        UpdateObjectValue = value;
                        break;
                    }

                    case "BorderStyle":
                    {
                        bool isApplyBorder = Convert.ToBoolean(value);
                        if (isApplyBorder)
                        {
                            UpdateObjectValue = BorderStyle.FixedSingle;
                        }
                        else
                        {
                            UpdateObjectValue = BorderStyle.None;
                        }
                        break;
                    }

                    case "CellBorderStyle":
                    {
                        bool isApplyBorder = Convert.ToBoolean(value);
                        DataGridViewAdvancedCellBorderStyle borderStyleValue = DataGridViewAdvancedCellBorderStyle.Single;
                        if (isApplyBorder)
                        {
                            borderStyleValue = DataGridViewAdvancedCellBorderStyle.Single;
                        }
                        else
                        {
                            borderStyleValue = DataGridViewAdvancedCellBorderStyle.None;
                        }
                        ValueForObjectInString = borderStyleValue.ToString();
                        UpdateObjectValue      = borderStyleValue;
                        break;
                    }

                    case "ForeColor":
                    {
                        UpdateObjectValue = colorValue;
                        break;
                    }

                    case "TextAlign":
                    {
                        ContentAlignment c = (ContentAlignment)Enum.Parse(typeof(ContentAlignment), textAlign_Cmbx.SelectedItem.ToString());
                        UpdateObjectValue = c;
                        break;
                    }
                    }
                }
                if (UpdateObjectValue != null)
                {
                    if (!string.IsNullOrEmpty(ValueForObjectInString))
                    {
                        item.SetValue(SelectedObject, Enum.Parse(UpdateObjectValue.GetType(), ValueForObjectInString));
                    }
                    else
                    {
                        item.SetValue(SelectedObject, UpdateObjectValue);
                    }
                    invokeUpdate();
                }
            }
        }