Hi John
ThisForm.AddObject(cmbField,"ComboBox") will add a combo to a form (I
would place code in init of form)
ThisForm.AddObject(cFieldsLabel,"Label") will add a label
The add the properties with ThisForm.cmbField.Top = 20,
ThisForm.cmbField.Left = 100 etc
However in my purchase orders form I populate the form with checkbox's
for the people oho may need to be emailed. I set up the maximum
required placed were I wanted them to show and then made them invisible.
I then used the code below to populate them as required.
Local lcDeleted,lnCheckBoxNo,lcCheckBoxName,lcProperty,lcSuffix
lnCheckBoxNo = 1
lcDeleted = Set("deleted")
Select EmailDetails && Email address table
Set Deleted On
lcSuffix = Alltrim(Thisform.txtSuffix.Value) && Employee initials
(Employee creating Purchase Order)
If Atc(" ",lcSuffix) > 0
lcSuffix = Left(lcSuffix,Atc(" ",lcSuffix) -1)
Endif
Select EmailDetails
Scan For Alltrim(EmailDetails.POPrefix) = lcSuffix && PO Prefix is
employees who this employee emails
lcCheckBoxName = "ThisForm.Check" + Transform(lnCheckBoxNo) +
"." && Check box's have been left as Check1 etc
lcProperty = lcCheckBoxName + "Caption"
&lcProperty = Alltrim(EmailDetails.CopyTo) && Employees initials
(Copy this PO to.)
lcProperty = lcCheckBoxName + "Visible"
&lcProperty = .T.
lcProperty = lcCheckBoxName + "BackStyle"
&lcProperty = 0
lcProperty = lcCheckBoxName + "Value"
If EmailDetails.lEmail
&lcProperty = 1
Else
&lcProperty = 0
Endif
lnCheckBoxNo = lnCheckBoxNo + 1
Endscan
Thisform.lnnoofemails = lnCheckBoxNo -1 && for use elsewhere for
scanning who needs to be emailed.
Set Deleted &lcDeleted
Cheers
Peter
Peter Hart Computers
-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of John Weller
Sent: 22 April 2009 21:15
To: [email protected]
Subject: Adding Objects to a Form
I have always created my forms at design time using the Form Designer.
I
now need to create and populate a form on the fly with an unknown number
of
labels and comboboxes. The app will be importing a text file with a
header
row showing the fields in the file. There may be any number of fields
(up
to say 30) and they may be in any order. I need to display each field
with
an associated combobox containing a list of standard field names to
allow
the user to match the fields in the header with those in the standard
list.
I haven't a clue where to start <g>. I am proposing to create a form in
the
Form Designer initially with a title and buttons then add the rest with
code
at run time. Can anyone point me to some code in Help or elsewhere
which
will give me a start on how to add an object to a form? Where should I
put
the code on the form - Init? Each combobox will use the same array or
cursor of standard field names - can I use an array property of the
form?
TIA
John Weller
01380 723235
07976 393631
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/a57fa4cf19531343a2ee11b57db8e3af04c...@server.peterhartcomputers.local
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.