[Mono-winforms-list] [BUMP] ToolStripDropDown + UserControl

Alex Shulgin alexander.shulgin at yessoftware.com
Wed Mar 4 12:44:44 EST 2009


Jonathan Pobst wrote:
> How about this one?

Yes, this patch fixes my issue.

Unfortunately, it breaks things elsewhere: see attached screenshot for 
the sample.

I'm using the following definition of PopupMenu with the rest of my 
previously sent sample file untouched:

     public class PopupMenu : ToolStripDropDown
     {
         public PopupMenu()
         {
             ToolStripMenuItem menuItem1 = new 
ToolStripMenuItem("menuItem1");
             menuItem1.DropDownItems.Add("test1");
             ToolStripLabel label1 = new ToolStripLabel("label1");
             ToolStripButton button1 = new ToolStripButton("button1");
             ToolStripDropDownButton ddbtn1 = new 
ToolStripDropDownButton("ddbtn1");

             this.Items.Add(menuItem1);
             this.Items.Add(label1);
             this.Items.Add(button1);
             this.Items.Add(ddbtn1);
         }
     }

I'm now trying to properly override CalcPreferredSize method in 
ToolStripItem-derived classes to fix the whole issue.  My progress on 
this is, well... fair. ;)

BTW, lets not forget about ToolStripDropDownMenu--it has it's own 
copy-pasted implementation of OnLayout method with minor changes.

--
Alex

> Jonathan
> 
> 
> Alex Shulgin wrote:
>> Jonathan Pobst wrote:
>>>>> Does the attached patch fix the issue for you?
>>>>
>>>> Well, partially.
>>>>
>>>> The height is determined correctly, but there's still extra 
>>>> decoration to the left and right of the hosted item as demonstrated 
>>>> on attached screenshot.
>>>
>>> Like your first email says, we need to figure out why that 68 is 
>>> there.  It is a crutch to support the common case, but it messes up 
>>> less common cases like this.
>>>
>>> While your patch works around the issue, its not the correct 
>>> solution. This 68 needs to be dynamically calculated from something, 
>>> whether its margins or paddings or preferred sizes of MenuItems.
>>>
>>> I will try to look at this some this week if you don't want to dig 
>>> any deeper.
>>
>> Hi,
>>
>> Thanks for your responses!
>>
>> Apparently, .NET ToolStripDropDown behaves differently when it's 
>> hosted inside ToolStrip and when it's used standalone.
>>
>> I'm attaching a sample .cs and a PNG screenshot to demonstrate the 
>> difference.
>>
>> So possibly, the correct solution would be to introduce some flag that 
>> indicates the drop down is used standalone (or determine this from the 
>> existing data like missing Owner, etc.) and adjust layout and painting 
>> accordingly.
>>
>> -- 
>> Alex
>>
>> ------------------------------------------------------------------------
>>
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tsdd-patch-broken-menu.png
Type: image/png
Size: 6690 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-winforms-list/attachments/20090304/ff82d6e0/attachment.png 


More information about the Mono-winforms-list mailing list