[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Combobox with an array that gets lengthened

Posted on 2009-12-19
3
Medium Priority
?
830 Views
Last Modified: 2012-05-08
I've got a combobox with the RowSourceType property set to 5, to use an array.

The last row in the array contains an entry "new". Selecting this allows you to add an extra entry into the list.

Except that once I've added the new entry, I lose the "new" entry at the end of the list.

I think that what's happening is that when I first set up the combobox, VFP works out that it has (say) 200 rows. Adding the extra row means that the array now has 201 rows, with "new" in the 201st row. But VFP still thinks that the array has 200 rows.

I've looked through the object's properties using DEBUG, but the only obvious property is .LISTCOUNT, which is read-only.

Is there another property that I should have incremented in some way?
0
Comment
Question by:IainMacb
3 Comments
 
LVL 30

Expert Comment

by:Olaf Doschke
ID: 26090106
I don't know from the top of my head, but perhaps VFP indeed copies the array you specify to it's own List() array, try adding to it with additem().

Otherwise a cursor may be the easier rowsource in that case, new records in a cursor will be reflected in the combobox right away.

Bye, Olaf.
0
 
LVL 43

Accepted Solution

by:
pcelba earned 1000 total points
ID: 26090317
AddItem does not help here.

If you change the RowSource array dimension you have to call Combo's Requery method to update the number of displayed options.

Following code works in Combo's Valid event (macro substitutions are there just for testing puproses):
WITH THIS
  
  IF .Value = '<New>' AND .RowSourceType = 5
    lcSource = .RowSource
    &lcSource[ALEN(&lcSource)] = 'New opt ' + TIME()
    DIMENSION &lcSource[ALEN(&lcSource)+1]
    &lcSource[ALEN(&lcSource)] = '<New>'
    .Requery
  ELSE
    WAIT WINDOW "Combo selection: " + .Value NOWAIT
  ENDIF
  
ENDWITH

Open in new window

0
 
LVL 1

Author Comment

by:IainMacb
ID: 26092573
REQUERY() method does the trick. Excellent!

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
In the below post we have mentioned the best hosting type for startups. Also, check out some of the superlative web hosting companies that are proposing affordable web hosting solutions to host your startup website.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question