First off, I'm ecstatic that this has been developed... a step in the right direction! However, I have one tiny suggestion and it's purely from a UI perspective.
I think if the calculated drop down width is less than the RadComboBox
width, it should "default" to the RadComboBox width. If you view my attachment (the too short one), you'll see what happens.
I love that this is done on the client side and would really love to know if there's a work around. Otherwise, I think I'm going to use my "in house" method which is done via server side (and isn't as efficient). This isn't code completely written by me, but I'll post what I currently have in case there are any suggested workarounds or if others are interested.
I have a general utility that calculates the width of text:
fontSize = 15)
(var textBitmap =
(var drawGraphics = Graphics.FromImage(textBitmap))
(var drawFont =
System.Drawing.Font(fontName, fontSize, GraphicsUnit.Pixel))
And then I have an extension method:
var rcbWidth = Utilities.TextWidth(comboBox.Items.OrderByDescending(i => i.Text.Length).Take(1).Select(i => i.Text).First());
rcbWidth <= comboBox.Width.Value ? comboBox.Width : rcbWidth;
So, in my code behind I just have something like:
rcbSalesReps.DropDownWidth = rcbSalesReps.AutoDropDownWidth();
Just something to consider. To me, if I look at the attachments, I think the "just right" version looks much better than the "too short" one.
I'm open to any ideas or suggestions!