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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine if an contained object exists

Status
Not open for further replies.

lordhawkins

Programmer
Sep 25, 2003
64
SV
Is there a way to show if an combobox added to column in a grid with addobject still remains within the form. The form hasn't been released, but sometimes -haven't discovered yet why -the object dissapears as it has beem removed...

Tnx for your help
 
lordhawkins

but sometimes -haven't discovered yet why -the object dissapears as it has beem removed

This is not normal behavior, I would investigate the problem rather than trying to determine if the object is still there or not. But one thing that may cause this problem, is if you change or reset the grid's recordsource, and in that process the grid is rebuild and in that process you loose the combo, as it rebuilds a new grid.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Indeed the recordsource is changed for this grid, as a result from an afterRowColChange on another one. The entire arrangement in the form is like this:

Field for Lot No. _____

Grid with chemical process for the lot (grdProcess

Grid with the chemicals used in the process (grdFormula)


The "operation" in the form is like this

If you change the Field Lot No. it summon a method for refilling the PROCESSES grid. If there are chemicals, they are displayed in the CHEMICALS grid.

As you you displace for the PROCESSES grid, CHEMICALS get a recordsourcetype = 0 and a recordsource = "". Then the recordsource is selected with an SQL command to cursor "cComponents" and the grid receives a recordsourcetype=1 and a recordsource= "cComponents"

The combobox is added in the init of the CHEMICALS grid with this
Code:
WITH thisformset.prodhilo.grdformula
	.readonly=.f.
	.column2.removeobject("Text1")
	.column2.addobject("cmbUnimed","combobox")
	.column2.CurrentControl="cmbUnimed"
	.column2.cmbUnimed.rowsource="Select unidad,id from unimed into cursor cphUnid"
	.column2.cmbUnimed.rowsourcetype=3
	.column2.cmbUnimed.style=2
cprocesos.idunimed with cphunid.id"
	.column3.readonly=.f.
	.RowHeight=21
ENDWITH

May be something with the creation of the object?

Tnx for your time
 
You may want to take a look at faq184-1813

Especially the line
Code:
thisform.grid1.recordsource=""

Use it prior to changing your grid.recordsource

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I'm using the command for recordsource as indicated (this tip I learned here a year ago). How could I recreate the the combobox again ONLY if it is non-existent? Should it go inside the AfterRowColChange of the grid with the Processes?
 
To answer your original question - you can spin thru the form / container and see what objects appear. Here is an example of just the form objects:

Code:
FOR EACH loTxt IN THISFORM.objects
   IF INLIST(UPPER(loTxt.baseClass),"TEXTBOX","EDITBOX","LISTBOX")
      MESSAGEBOX(loTxt.Name)
   ENDIF
ENDFOR

This 2nd example is more indepth, it spins a form/pageframe and builds a command to enable or disable the controls - then executes the command.

Code:
lcAllowEdits = ".T."  && hardcode for demo purposes
FOR EACH loTxt IN THISFORM.pgfMain.page1.objects
   IF INLIST(UPPER(loTxt.baseClass),"TEXTBOX","EDITBOX","LISTBOX")
      lcCmd = "THISFORM.PgfMain.page1." + loTxt.Name + ".ENABLED = " + lcAllowEdits 
      &lcCmd
   ENDIF
ENDFOR


Jim Osieczonek
Delta Business Group, LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top