Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combobox not displaying all values

Status
Not open for further replies.

mkrausnick

Programmer
Apr 2, 2002
766
US
I create the dropdown list in the INIT event with this code:
Code:
* Current FY import directory
nFY = fy(date())
m.cStartImp = SYS(5)+gcImportDir+RIGHT("000"+ALLTRIM(STR(nFY)),4)+"\"
THIS.AddItem(m.cStartImp)

* Prior FY import directory
This.AddItem( SYS(5)+gcImportDir+RIGHT("000"+ALLTRIM(STR(nFY-101)),4)+"\")
THIS.Value = m.cStartImp
THIS.DisplayValue = m.cStartImp

The problem is that only the first value is shown when I click the dropdown arrow. I want both values to be present when I click the dropdown arrow. In this example the combobox should contain:
H:\IMPORT\0607\ and
H:\IMPORT\0506\.

RowSource and RowSourceType are both NONE. The control is not bound. DisplayCount and Number of Elements are both zero, but the result is the same if I change them to 2.

FY() is a function that creates a numeric 4 digit fiscal year, e.g. 0607 (or 607 in this case) for FY 2006-2007.

What am I doing wrong?

Mike Krausnick
Dublin, California
 
Try using AddListItem instead of AddItem.
Also, you may want to use "\\" instead of just "\".

A single \ means something along the lines of 'interpret the next character as a literal'. So it could screw with your string.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Hi Mike.

The AddItem() method will do exactly whyat you are trying to do. You do not need to use the AddListItem() method instead. In theory, what you have posted should work.

To try to debug this, why don't you try this:

Code:
lcItem = SYS(5)+gcImportDir+RIGHT("000"+ALLTRIM(STR(nFY-101)),4)+"\"
This.AddItem( lcItem )

At least that way, you can actually see what is in the variable.

Also, it is not necessary to set the combo's DisplayValue.


Marcia G. Akins
 
I tried Marsha's suggestion, even put in a messagebox to display the value of lcItem - it's correct.

How about this for strange:

The combo-box resides in a pageframe page. I copied the control onto the form outside the pageframe, and it works correctly! Two identical combo-boxes, one in a pageframe page and the other not, and they give differing results.

The page has no method code. The pageframe has only a resize event with a one-liner to resize a grid that resides on another page of the pageframe.

BTW this is VFP9 build 09.00.0000.2412.

Can someone try this and see whether it's just me?

Mike Krausnick
Dublin, California
 
Installed VFP9 SP1 - no change. Any help would be appreciated.

Mike Krausnick
Dublin, California
 
Since the Init of controls fires before the Init of the parent container, maybe you need to run your original code in the Init of the form rather than the Init of the drop-down.(?)
The value nFY may change depending on scope.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Found that another form method was re-initializing the combobox, keeping only the first value. Arrggghhhh!

Thanks for taking the time anyway.


Mike Krausnick
Dublin, California
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top