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

List of Command Buttons Caption and Name 2

Status
Not open for further replies.

ramani

Programmer
Mar 15, 2001
4,336
AE
I have a form with several PageFrames. For some specific reason, I need to collect all the command buttons in the form to a table with names in one column and the respective command in another column. Since the command buttons undergo changes during the development process, I need to refresh these collections to the table again and again. Is there a simple way to get this into an array or a table. Right now I key in the names and the commands by hand in a table. Doing automaticaly will help me avoid the 'donkeys' job.. which I do now.. -:)
 
Is there a simple way to get this into an array or a table.

I'm not sure about 'simple', but I'm sure you can do it with a little work. There's some list of all the objects in a form which you can use to pick out the command buttons (I forget just what the name is as I don't have VFP up on the computer just now). Then you'd just need a little program to run when desired which will get the name of the button and stuff it into the table.

Or perhaps you can simply access the table which lists the stuff in the form and filter out what you need. Which brings up a question of my own. I've been told that the information for a foxpro program is in the form of a table, but I'm not sure just what you have to do to access it. When I try looking at the various things which are supposed to be tables I'm told they're not tables.

Dave Dardinger
 
ramani

The array you require is already exists - look up Controls in the VFP Help file.

The following code will loop through all the controls in a container.

FOR lnRow = 1 TO THIS.ControlCount
[tab]WAIT WIND THIS.Controls[lnRow].Name
ENDF

Dave

Tables are used for projects, forms, reports etc and are accessible by:-

USE myform.scx IN 0 && Opens a form
SELE myform
BROW

Chris :)
 
Hello

Just to be sure that the Christ's post is correctly understood:

The "container" is the form. If the form contains a container, the array Form.Controls is not enough.

You'll have to do a recursive scan of the controls, to determine if the baseclass of every of them belongs to "PageFrame", "CommandGroup", "Container" (optiongroup usually does not contain pushbuttons). If so, in this case you'll have to scan the Container.Controls.

(This was wrote in hurry. If you need more information, reply, please).

Hope this helps
Grigore Dolghin
Class Software
Bucharest, Romania
 
Grigore

Without wishing to cause offence to those of a religious nature, I suspect a typo in - Just to be sure that the Christ's post is correctly understood: - thanks for the elevation!

Your fuller explanation of the word container is appreciated - I deliberately avoided the use of a specific container such as THISFORM.Controls for that reason, and also did not have time for the proper explanation that you subsequently provided.

Chris :)
 
Chris,

:)))).

Yes, this is a typo. Thanks for spotting it, and I'm sorry if it is offensive.
Grigore Dolghin
Class Software
Bucharest, Romania
 
As one who is religious, and with Easter coming up, I would actually like "to be sure that the Christ's post [= the Cross] is correctly understood" :p. But that takes us outside the scope of this forum so I'll let it drop. --Dave
 
Since you're not asking for a runtime process:

Code:
SELECT * FROM MyForm.scx ;
WHERE BASECLASS=='commandbutton' ;
INTO CURSOR 'MyTemp'

IF RECCOUNT('MyTemp')<1
  ? 'Nuttin to do'
  RETURN .F.
ENDIF

SCAN
  ? 'Hello, my name is ' + MyTemp.ObjName
  lnLines = ALINES(MyArray,MyTemp.Properties)
  FOR lnCounter= 1 TO lnLines
     IF LEFT(MyArray(lnCounter),8)=='Caption '
       lcAKA=ALLT(STRT(SUBS(MyArray(lnCounter),10),'&quot;',''))
       ? 'AKA: ' + lcAKA
     ENDIF
  ENDFOR
ENDSCAN
USE
Jon Hawkins

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top