Setting the Width of a Drop Down, Combo Box, or Edit Box in the Ribbon Designer (Norm Estabrook)

  • Comments 6

Recently, a developer posted a question to the VSTO forum asking us how to set the width of a drop down control by using the Ribbon Designer (http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/8965ae5a-9c02-4aec-9178-675650b7044e/).

As this person experienced, if you do not set the width of the control, the text that appears in a drop down, combo box, or edit box will truncate. For example, the string “I love Visual Studio Tools for Office!” is truncated in the following drop down:

clip_image002

So how do you fix this? The magic lies in the SizeString property. However, the use of this property is not so obvious. Instead of setting this property to a number such as 20 for 20 characters of space, you must type an actual character for each character’s worth of space you want to allocate for the text width.

For example, to make enough space for the string “I love Visual Studio Tools for Office!”, set the SizeString property of the drop down to “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx” or “jlkjlkjlkjlkjdlslaledfoplklksjjklsfdf” etc.

You can also decrease the size of the text area to show fewer characters than appear by default. For example, just set SizeString to “xx” if you want only two characters to appear.

Norm E.

Leave a Comment
  • Please add 6 and 7 and type the answer here:
  • Post
  • Would you recommend (or not recommend) using "W" as the sizing character, given that it would be the widest en-US character?

  • Great tip - but how can you control the size of the label?

  • The size of the label expands automatically to accomodate the length of the text.

  • Thanks, I couldn't figure out how to do this.

    Is there any specific reason why this approach is required? It just seems really weird to me that you actually have to supply a lengthy string instead of just a number that specifies the width?

  • Thanks for the tips Norm.

    I agree with Dennis, it's so strange and funny when seeing this. Wondering if there's any rationale behind.

  • Here is the process I just took:

    1. Looked through the properties pane in the Ribbon designer when I had my  RibbonDropDown selected and found nothing for setting a size.

    2. Checked to see if the size was based on the data inside it (it wasn't)

    3. Checked through the list of parameters on an instances of the RibbonDropDown, found a .SizeString property.

    4. Pressed F1 which took me to the online help here: msdn.microsoft.com/.../dev11.query

    which not surprised to say was completely useless.

    5. It was also mis-leading because I started trying to set what you may logically thing would represent some sort of unknown size of measurement in a string ?!?

    6. Gave up and typed in SizeString to Google and thankfully found this post that describes the most ridiculous way to set a size that I have possibly ever seen.

    Again I don't think I want to know if or what any of the reasoning was behind this, but I'm already starting to regret even considering using VSTO.

    Thanks anyway to Norm for putting something useful online, but as this is a MSDN blog? couldn't you put a good word in and get them to update the MSDN help page for the property???

Page 1 of 1 (6 items)

Setting the Width of a Drop Down, Combo Box, or Edit Box in the Ribbon Designer (Norm Estabrook)