Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ListBox Problem
Message
From
10/11/1997 16:45:07
Murray Mcintosh
Mammography Reporting System, Inc.
Seattle, Washington, United States
 
 
To
10/11/1997 15:30:58
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00059296
Message ID:
00059387
Views:
38
>>I've run across a problem in Visual FoxPro 5.0 (including 5.0a) related to using using a listbox or a combobox. This applies to both the Runtime and Development versions of VFP. This does not apply to Visual FoxPro 3.0.
>>
>>For example, say there is a table named test1 with a character field named field1 with a tag on upper(field1) which is current, and you have a listbox where the rowsourcetype = 2 (alias) and the rowsource = "test1".
>>
>>If when the list gets the focus the current item in the list mod 256 equals 253 (or in otherwords, start with 253 then every 256th element thereafter) then bad things start to happen. I either get a somewhat erroneous error message or VFP just bails out altogether. At this point if you haven't already been tossed out of VFP it's a good idea to quit and restart it since it (VFP) may start acting strangly.
>>
>>
>>Here is some example code to reproduce the problem. Be sure to save any unsaved work in VFP before running this example:
>>
>>*********************************************************************
>>*********************************************************************
>> local oForm,m.i
>> on error
>> close data
>> create cursor Test1 ( field1 c(10))
>> index on upper(field1) tag ufield1
>> for m.i = 1 to 999
>> insert into test1 (field1) values("item " + padl(allt(str(m.i)),3,"0"))
>> endfor
>> oForm = createobject("Form")
>> with oForm
>> .caption = "Select item 253 and press Tab to see the error."
>> .AddObject('list1','listbox')
>> endwith
>> with oForm.list1
>> .visible = .t.
>> .rowsourcetype = 2
>> .rowsource = "Test1"
>> .listindex = 252
>> *** if listindex % 256 = 253 when the list gets the focus
>> *** the error will occur.
>> *** so listindex could be 253 or 509 or 765, etc.
>> *** set it to some other value to see it work properly.
>> *** pressing tab is one way to trigger it. You could also
>> *** just initialize the list index to 253.
>> endwith
>> oForm.Show(1)
>>
>>*********************************************************************
>>*********************************************************************
>>Run the above code and follow the instructions on the form's caption to see the error.
>>
>>The only workaround I've come up with is to check the listindex in the list's gotfocus event. Using a list with rowsourcetype = 0 is not a viable alternative with large lists for performance reasons.
>>
>>*** workaround code to put in the list's gotfocus event.
>>with this
>> if .listindex % 256 = 253
>> .listindex = .listindex - 1
>> .interactivechange()
>> endif
>>endwith
>>
>>Note.... This example uses rowsource = 2 to trigger the problem but other rowsource types can also trigger it. For example, if the list in the above example's rowsourcetype = 3 (SQL) and the rowsource was "Select field1,upper(field1) as ufield1 from test1 order by ufield1 into SomeCursor" the same problem occurs. Also, it may be that other functions besides "upper" could trigger the problem.
>>
>>I've submitted this problem to Microsoft via the internet on more than one occasion but never had any indication the message was ever read by anyone.
>>
>>Has anyone else out there seen this? Any other workaround ideas?
>
>Hi Murray,
>
>This is a documented bug. MS KB article Q164252 should help you out. If you can't get it, let me know :-).
>
>Bill

Thanks for the info, Bill (and Jim). I found the article. One of those cases where my searching fell a bit short. The article doesn't point out, however, the problem with the subsequent 256th elements of the list (so they didn't read my e-mail after all). Microsoft's workaround also falls a bit short in that for big lists a rowsource of 0 or 5 is not near as efficient as a rowsource of 2 or 3. Jim's idea of limiting the size of the list is a better solution but takes a bit more interface re-design than I'd like to do. Thanks again for the help.
Previous
Reply
Map
View

Click here to load this message in the networking platform