Example #1
0
		public override object EditValue(
			System.ComponentModel.ITypeDescriptorContext context,
			System.IServiceProvider provider, object value)
		{
			SelectDrive frm = new SelectDrive();

			// Set current drive in window.
			frm.DriveSelection = (char)value;
			frm.ShowDialog();

			// Return the new value.
			return frm.DriveSelection;
		}
        public override object EditValue(
            System.ComponentModel.ITypeDescriptorContext context,
            System.IServiceProvider provider, object value)
        {
            SelectDrive frm = new SelectDrive();

            // Set current drive in window.
            frm.DriveSelection = (char)value;
            frm.ShowDialog();

            // Return the new value.
            return(frm.DriveSelection);
        }
        protected void OnVerb(object sender, EventArgs e)
        {
            char oldValue = ((DirectoryTree)this.Control).Drive;
            char newValue;

            if (sender == verbSetDrive)
            {
                // Show the form.
                using (SelectDrive frm = new SelectDrive())
                {
                    frm.DriveSelection = oldValue;

                    // Exit in case Cancel is clicked.
                    if (frm.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    // Get the result.
                    newValue = frm.DriveSelection;
                }
            }
            else
            {
                // Retrieve the selected drive.
                newValue = ((DesignerVerb)sender).Text[10];
            }

            // Adjust the associated control.
            ((DirectoryTree)this.Control).Drive = newValue;

            // Notify the IDE that the Drive property has changed.
            PropertyDescriptorCollection properties;

            properties = TypeDescriptor.GetProperties(typeof(DirectoryTree));
            PropertyDescriptor changedProperty = properties.Find("Drive", false);

            this.RaiseComponentChanged(changedProperty, oldValue, newValue);
        }