>The ColumnWidth is in Pixels. Because most fonts used in Windows are proportional, there's not really a way to set a width to a number of characters. You'll probably just have to expirement with the widths until you get what you want. The alias.field, field, field,... syntax is correct. Put in column widths (eg, 100,150) and you should see the results you want.
>
Harry,
I'm sorry I missed your post on 11/6, I was on vacation at the time. The solution I use is to set column width dynamically based on the length of the longest trimmed string in a column. This may not always work. You may want to set a maximum column width. Here is my code snippet that does the job where the rowsource is an array. It should be adaptable to any type of rowsource. Here the array is a property of the combobox and is called .aRowSource[]. This snippet assumes that .aRowSource has already been filled from whatever is the data source.
I use FONTMETRIC to get the average character size of a bold character -- for some reason the average size of a normal character seems to result in a column with that is too small. You might want to experiment with this. The .picture in a combobox is that image that appears to the left of an item in the list. If you don't use a picture in your combobox, ignore the clause "IIF EMPTY(.picture),0,14)"
IF .rowsourcetype = 5
LOCAL i
FOR i = 1 TO ALEN(.aRowSource,1)
lnMaxChars = MAX(lnMaxChars,LEN(TRIM(.aRowSource[i,1])))
ENDFOR
.ColumnWidths = ALLTRIM(STR((lnMaxChars * FONTMETRIC ;
(6,.fontname,.fontsize,"B")) + ;
IIF(EMPTY(.picture),0,24)))
ENDIF
You can use this routine to set as many column widths as you want, just make sure they are strings and that each column width is separated by a comma.
You would probably want to put this routine in whatever metod you use to load your rowsource. If your rowsource is a table, then probably in the Init() event.
regards,
Jim Edgar
Jurix Data Corporation
jmedgar@yahoo.comNo trees were destroyed in sending this message. However, a large number of electrons were diverted from their ordinary activities and terribly inconvenienced.