Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
List Box Question
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Title:
List Box Question
Miscellaneous
Thread ID:
00933979
Message ID:
00933979
Views:
71
List Box question: (beginning VFP7/OOP programmer)
If you populate a list box programmatically, are the entries in the list box only active for a certain time? In the code below, I have two listboxes on a form. Objective is to interactively select fields in a table for deletion. The 1st listbox contains a list of tables one of which will be selected to have some fields deleted. The second listbox contains the fields in the table selected for deletion.
The second listbox won't accept selected item & I'm not experienced enought to know why.
The following is the code w/some explanation.

This code populates the 1st list box from an option group button & works OK.

thisform.bwlst1.RowSourceType= 7
thisform.bwlst1.RowSource = "*.dbf" &&list tables
thisform.bwlbl1.caption = "Select File containing Field/Column to be deleted;
and press Continue" && instructions to user


This code (in a command button) works OK to select the desired table and populate the 2nd listbox with the fields in the selected table.

OPEN DATABASE stkmktdat
m.lcfilnm = thisform.bwlst1.DisplayValue && file from listbox #1 for field deletion
USE (m.lcfilnm) IN 1
thisform.bwlbl2.Caption = "Select the Fields/Columns to be deleted and;
press Execute" &&instructions to user
COPY TO t1 &&copies file to be changed to a temporary file
COPY STRUCTURE EXTENDED TO t &&copies structure of file to t
USE t IN 1
thisform.bwlst2.RowSourceType = 2 &&populates listbox #2
thisform.bwlst2.RowSource = "t" &&
thisform.bwlst2.ControlSource = "field_name"

This code is from a 2nd command button and does not work OK because none of the fields selected show up “.T.” Why not?

m.licnt=2
m.lcfldnm=""
thisform.bwlst2.Requery()
FOR m.licnt = 2 TO thisform.bwlst2.ListCount STEP 1

&&debugging code
thisform.bwlst2.ListItemId = m.licnt
thisform.bwtxt1.Value = thisform.bwlst2.DisplayValue
DO mbox &&message box pause
thisform.bwtxt1.value = thisform.bwlst2.SelectedID(m.licnt)
DO mbox
&& end of debugging code

IF thisform.bwlst2.Selected(m.licnt) = .t.
m.lcfldnm = thisform.bwlst2.DisplayValue

&&debugging code
thisform.bwtxt1.Value = m.lcfldnm
DO mbox &&messagebox
&&end debugging code

ALTER TABLE t1 drop COLUMN (m.lcfldnm)
ENDIF
ENDFOR
USE IN 1
CLOSE DATABASES
DO FORM deladdmodtbl
Next
Reply
Map
View

Click here to load this message in the networking platform