2007-03-30
What's the width of a combo list
If you have a combobox for which you don't specify a value for the ColumnWidths property, Visual FoxPro has to figure out itself how wide the dropdown list should be. Basically, Visual FoxPro makes this list just wide enough to fully display its values. However, Visual FoxPro only parses part of the list to determine the actual width of each line. The following code sample demonstrates this behaviour:
Public goForm, gaData[121]
goForm = CreateObject("Form")
goForm.Show()
For lnRow=1 to 120
gaData[lnRow] = "_"+Transform(m.lnrow)
EndFor
gaData[121] = "AAAAAAAAAAAAAAA*"
* first combo
goForm.AddObject("c1","combobox")
goForm.c1.RowSource = "gaData"
goForm.c1.RowSourceType = 5
goForm.c1.ListIndex = 1
goForm.c1.Visible = .T.
* second combo
goForm.AddObject("c2","combobox")
goForm.c2.RowSource = "gaData"
goForm.c2.RowSourceType = 5
goForm.c2.ListIndex = 100
goForm.c2.Top = 50
goForm.c2.Visible = .T.
Both comboboxes are set up with identical row sources. The only difference between the two is the currently selected item. The first combo displays the first item, the second one an item that is close to the end. If you now open both comboboxes, you will notice that the first one is narrower and won't display the last item at its full length.
VFP uses the current element and then reads a varying number of lines. In the sample above it's always 68 on my computer. That is, with a ListIndex of 53, the combobox behaves like the first one, with a ListIndex of 54 like the second one. In other cases I found the number lines to be much more like 10 putting the long line just outside the visible area of the seven default lines.