Inheritance: System.Windows.Forms.UserControl
Example #1
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            // Return the value if the value is not of type ShapeType
            if (value.GetType() != typeof(ShapeType))
            {
                return(value);
            }

            // Uses the IWindowsFormsEditorService to display a
            // drop-down UI in the Properties window.
            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {
                // Display an Shape Type Editor Control and retrieve the value.
                ShapeTypeEditorControl editor = new ShapeTypeEditorControl((ShapeType)value);
                edSvc.DropDownControl(editor);

                // Return the value in the appropraite data format.
                if (value.GetType() == typeof(ShapeType))
                {
                    return(editor.shape);
                }
            }
            return(value);
        }
Example #2
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            // Return the value if the value is not of type ShapeType
            if( value.GetType() != typeof(ShapeType))
                return value;

            // Uses the IWindowsFormsEditorService to display a
            // drop-down UI in the Properties window.
            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if( edSvc != null )
            {
                // Display an Shape Type Editor Control and retrieve the value.
                ShapeTypeEditorControl editor = new ShapeTypeEditorControl((ShapeType)value);
                edSvc.DropDownControl( editor );

                // Return the value in the appropraite data format.
                if( value.GetType() == typeof(ShapeType) )
                    return editor.shape;
            }
            return value;
        }