Issue with ToolStripComboBox and padding

Uzamčený Issue with ToolStripComboBox and padding

  • 3. května 2012 19:34
     
     

    While I am asking this for VB I verified this issue also occurs in C# so I think it is a .NET issue.  i am using Visual Studio 2010 Premium Version 10.0.40219.1 SP1Rel with .NET Version 4.0.30319 SP1Rel.

    Step to recreate the problem.

    Create a new Windows Application  for Visual Basic (WinForms).

    Add a ToolStrip.

    Add a ToolStripComboBox to the ToolStrip.

    Save, note the width of the combo box.

    Change the padding on the combo pax to 2.

    Save and close the form designer.

    Reopen the form designer, look at combo box width - it decreased.  Note that form is marked as having been modified.  

    So save it and close the designer again.

    Reopen the designer and look at the combo box width - it will have shrunk every time you save, close, and reopen until you get to a 0 width.

    It shrinks by 4 * the padding size.

    Why is this behavior happening?  Why would padding affect the size since that is the interior margin where as the margin settings are the exterior margins.

Všechny reakce

  • 4. května 2012 6:53
     
     

    Hi Kevin,

    I'm using VS2010 Ultimate version and I can't re-appearance your issue. It works well for me. So would you please post some screen shot about this?


    No code, No fact.

  • 4. května 2012 7:49
    Moderátor
     
     Odpovědět

    Hi Kevin,

    Thanks for your post.

    You can avoid this issue by setting the AutoSize of ToolStripComboBox property to False.

    Control.Padding Property will influence in the size of the control when the AutoSize of the control set to true, because the Control will change himself to suit the Padding property. Please check the Control.Padding Property: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.padding.aspx

    Controls receive default values for Padding that are reasonably close to Windows user interface guidelines. Some adjustments might still be necessary for particular applications.

    All controls that implement GetPreferredSize are enlarged by the amount in Padding when AutoSize is true.

    As for this phenomenon, I have no idea about whether it is by design.  You can submit it to Microsoft Connect feedback portal http://connect.microsoft.com , Microsoft engineers will evaluate them seriously, thanks.

    Hope this helps.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us

    • Označen jako odpověď Kevin Jonas 4. května 2012 14:46
    •  
  • 4. května 2012 14:45
     
     

    Interesting.  Though that says "enlarged" it is interesting that in this case it is shrinking.  Switching autosize to false it shrinks twice then stops.

    I had two other developers here try it out on both VB and C# and they were able to reproduce it.  

    Thanks