PropertyGrid Commands/Verbs drawing problem
I'm using the PropertyGrid in my application to allow users to change settings.
I used the code at this link as the basis for adding Command support to my PropertyBag class so that the user can click them for actions.
http://blogs.crankygoblin.com/blogs/geoff.appleby/archive/2005/06/16/64688.aspx
That code is working correctly, however the window where the commands (or verbs) are being drawn grows vertically with each new command. So if I have only 1 command it draws correctly, but if I have 2 commands, it makes space for two rows of commands even though the commands all fit on one line.
Using Reflector, I looked into the .NET Framework code and found the HotCommands class. It implements the GetOptimalHeight method like this:
publicoverrideintGetOptimalHeight(int width){
if (this.optimalHeight ==-1)
{
intnum1 = (int) (1.5 *this.Font.Height);
intnum2 =0;
if (this.verbs !=null)
{
}
this.optimalHeight = (num2 *num1) +8;
}
returnthis.optimalHeight;
}
As you can see, the number of verbs (num2) is multiplied by the height each item should be which makes the vertical height grow for each command.

