There is a work-around for this that does not require reflection and munging the weirdness of the PropertyGrid. Try this:
1. create a UserControl, put a Button in it named 'button1, or whatever.
2. set the UserControl's AutoSize, SizeMode, Padding, Properties, etc., as you require.
3. set the Button's AutoSize and SizeMode properties as you require. Size and position the Button in the UserControl where you want it.
... think about the possible interactions here of changing, for example, the FontSize at run-time: if both the UserControl and the Button have their AutoSizeMode Properties set to 'GrowAndShrink, and their AutoSize Mode set to 'Auto: then the Size of both Button and UserControl will change ...
4. compile, and drag-drop instances of 'ButtonExLimited onto your Form as you require
5. example: when you want to edit the exposed Properties in a Property Grid:
propertyGrid1.SelectedObject = testButtonPropsExpose1.TheExposed;
6. example: when you to add an Event Handler to Button:
testButtonPropsExpose1.TheExposed.TheControl.Click += TheControl_Click;
7. Code for the UserControl:
using System.Drawing;
using System.Windows.Forms;
namespace YourNameSpace
{
public partial class TestButtonPropsExpose : UserControl
{
public TestButtonPropsExpose()
{
InitializeComponent();
TheExposed.TheControl = this.button1;
}
public TheExposedProps TheExposed = new TheExposedProps();
}
public class TheExposedProps
{
public Control TheControl;
public string Text
{
get { return TheControl.Text; }
set { TheControl.Text = value; }
}
public Color ForeColor
{
get { return TheControl.ForeColor; }
set { TheControl.ForeColor = value; }
}
public new Font Font
{
get { return TheControl.Font; }
set { TheControl.Font = value; }
}
}
}
Notes:
1. in production code I use a fancier version of this I intend to publish on CP