View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
J.S.Winstrom J.S.Winstrom is offline
external usenet poster
 
Posts: 8
Default ComboBox listwidth to match text in list

?B?SmltIFRob21saW5zb24=?=
wrote in
on Thu 02 Aug
2007 02:22:01p:

Gary - The problem with what you have shown is that len returns the
number of characters, not the sum of the widths of all of the
characters. Each character is a different size.

Atomic - To your question about list width / column width. Unless you
choose a non-proportional font like courier you are going to run into
problems. The width of i and the width of z are very different. If you
coose courier then you can traverse your list of entries an determine
the max number of characters an multiply that by the size of 1
character to determine your width... My preference is still just to
hard code a width that will accomodate darn near anything.


Jim: Thanks again for helping out. The only problem with hard-coding the
length is there is too much of a range in widths. The data loaded into any
given combo in my userform is loaded from an external access database. So
the text length could range from "A" to
"Supercalifragilisticexbeealidocious". So, if I can, I need to figure out a
method or formula of determining the width of the largest entry at any
given time.

Gary: Thanks for the input. Unfortunately, James is right. It returned the
largest number of characters and set the listwidth to 10 points when, in
actuality, it needed to be about 52 points.