Exemplo n.º 1
0
            /// <summary>
            /// Edits the specified object's value using the editor style indicated by the
            /// System.Drawing.Design.UITypeEditor.GetEditStyle() method</summary>
            /// <param name="context">An System.ComponentModel.ITypeDescriptorContext that can be used to gain
            /// additional context information</param>
            /// <param name="provider">An System.IServiceProvider that this editor can use to obtain services</param>
            /// <param name="value">The object to edit</param>
            /// <returns>The new value of the object. If the value of the object has not changed, this should
            /// return the same object it was passed.</returns>
            public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
            {
                m_editorService = provider.GetService(
                    typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

                if (m_editorService != null)
                {
                    StandardValuesListBox listbox = new StandardValuesListBox(this);
                    listbox.SelectedIndexChanged += listbox_SelectedIndexChanged;

                    System.Collections.ICollection values = m_converter.GetStandardValues(context);
                    foreach (object item in values)
                    {
                        if (!listbox.Items.Contains(item))
                        {
                            listbox.Items.Add(item);
                        }
                    }

                    listbox.SelectedItem = value;

                    m_editorService.DropDownControl(listbox);

                    if (listbox.SelectedItem != null)
                    {
                        return(listbox.SelectedItem);
                    }
                }

                return(value);
            }
Exemplo n.º 2
0
            /// <summary>
            /// Edits the specified object's value using the editor style indicated by the
            /// System.Drawing.Design.UITypeEditor.GetEditStyle() method</summary>
            /// <param name="context">An System.ComponentModel.ITypeDescriptorContext that can be used to gain
            /// additional context information</param>
            /// <param name="provider">An System.IServiceProvider that this editor can use to obtain services</param>
            /// <param name="value">The object to edit</param>
            /// <returns>The new value of the object. If the value of the object has not changed, this should
            /// return the same object it was passed.</returns>
            public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
            {
                m_editorService = provider.GetService(
                    typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

                if (m_editorService != null)
                {
                    StandardValuesListBox listbox = new StandardValuesListBox(this);
                    listbox.SelectedIndexChanged += listbox_SelectedIndexChanged;

                    System.Collections.ICollection values = m_converter.GetStandardValues(context);
                    foreach (object item in values)
                        if (!listbox.Items.Contains(item))
                            listbox.Items.Add(item);

                    listbox.SelectedItem = value;

                    m_editorService.DropDownControl(listbox);

                    if (listbox.SelectedItem != null)
                        return listbox.SelectedItem;
                }

                return value;
            }