Beispiel #1
0
        /// <summary>
        /// Construct a CellEditor for the specified type
        /// </summary>
        /// <param name="p_Type">Cell Type</param>
        /// <param name="p_DefaultValue">Default value of the editor</param>
        /// <param name="p_bAllowNull">Allow null</param>
        /// <param name="p_StandardValues">List of available values or null if there is no available values list</param>
        /// <param name="p_bStandardValueExclusive">Indicates if the p_StandardValue are the unique values supported</param>
        /// <param name="p_TypeConverter">Type converter used for conversion for the specified type</param>
        /// <param name="p_UITypeEditor">UITypeEditor if null must be populated the TypeConverter</param>
        /// <returns></returns>
        public static Cells.Editors.EditorBase Create(Type p_Type,
                                                      object p_DefaultValue,
                                                      bool p_bAllowNull,
                                                      System.Collections.ICollection p_StandardValues,
                                                      bool p_bStandardValueExclusive,
                                                      System.ComponentModel.TypeConverter p_TypeConverter,
                                                      System.Drawing.Design.UITypeEditor p_UITypeEditor)
        {
            Cells.Editors.EditorBase l_Editor;
            if (p_UITypeEditor == null)
            {
                if (p_StandardValues != null)
                {
                    Cells.Editors.ComboBox editCombo = new Cells.Editors.ComboBox(p_Type);
                    l_Editor = editCombo;
                }
                else if (p_TypeConverter != null && p_TypeConverter.CanConvertFrom(typeof(string)))//txtbox
                {
                    Cells.Editors.TextBox l_EditTextBox = new Cells.Editors.TextBox(p_Type);
                    l_Editor = l_EditTextBox;
                }
                else //if no editor no edit support
                {
                    l_Editor = null;
                }
            }
            else //UITypeEditor supported
            {
                Cells.Editors.TextBoxUITypeEditor txtBoxUITypeEditor = new Cells.Editors.TextBoxUITypeEditor(p_Type);

                //[email protected]: Check if Control exists
                if (txtBoxUITypeEditor.Control != null)
                {
                    txtBoxUITypeEditor.Control.UITypeEditor = p_UITypeEditor;
                }
                l_Editor = txtBoxUITypeEditor;
            }

            if (l_Editor != null)
            {
                l_Editor.DefaultValue = p_DefaultValue;
                l_Editor.AllowNull    = p_bAllowNull;
                //l_Editor.CellType = p_Type;
                l_Editor.StandardValues          = p_StandardValues;
                l_Editor.StandardValuesExclusive = p_bStandardValueExclusive;
                l_Editor.TypeConverter           = p_TypeConverter;
            }

            return(l_Editor);
        }
Beispiel #2
0
        /// <summary>
        /// Construct a CellEditor for the specified type
        /// </summary>
        /// <param name="p_Type">Cell Type</param>
        /// <param name="p_DefaultValue">Default value of the editor</param>
        /// <param name="p_bAllowNull">Allow null</param>
        /// <param name="p_StandardValues">List of available values or null if there is no available values list</param>
        /// <param name="p_bStandardValueExclusive">Indicates if the p_StandardValue are the unique values supported</param>
        /// <param name="p_TypeConverter">Type converter used for conversion for the specified type</param>
        /// <param name="p_UITypeEditor">UITypeEditor if null must be populated the TypeConverter</param>
        /// <returns></returns>
        public static Cells.Editors.EditorBase Create(Type p_Type,
            object p_DefaultValue,
            bool p_bAllowNull,
            System.Collections.ICollection p_StandardValues,
            bool p_bStandardValueExclusive,
            System.ComponentModel.TypeConverter p_TypeConverter,
            System.Drawing.Design.UITypeEditor p_UITypeEditor)
        {
            Cells.Editors.EditorBase l_Editor;
            if (p_UITypeEditor == null)
            {
                if (p_StandardValues != null)
                {
                    Cells.Editors.ComboBox editCombo = new Cells.Editors.ComboBox(p_Type);
                    l_Editor = editCombo;
                }
                else if (p_TypeConverter != null && p_TypeConverter.CanConvertFrom(typeof(string)))//txtbox
                {
                    Cells.Editors.TextBox l_EditTextBox = new Cells.Editors.TextBox(p_Type);
                    l_Editor = l_EditTextBox;
                }
                else //if no editor no edit support
                {
                    l_Editor = null;
                }
            }
            else //UITypeEditor supported
            {
                Cells.Editors.TextBoxUITypeEditor txtBoxUITypeEditor = new Cells.Editors.TextBoxUITypeEditor(p_Type);
                txtBoxUITypeEditor.Control.UITypeEditor = p_UITypeEditor;
                l_Editor = txtBoxUITypeEditor;
            }

            if (l_Editor != null)
            {
                l_Editor.DefaultValue = p_DefaultValue;
                l_Editor.AllowNull = p_bAllowNull;
                //l_Editor.CellType = p_Type;
                l_Editor.StandardValues = p_StandardValues;
                l_Editor.StandardValuesExclusive = p_bStandardValueExclusive;
                l_Editor.TypeConverter = p_TypeConverter;
            }

            return l_Editor;
        }