Hi all,

I've recently started working on a project using
microsoft visual foxpro 8.0. Unfortunately i met with
some problems creating checkboxes wif values retrieved
from a database table.

Any help is appreciated.

Thanks

creating check boxes programmatically by Ee

Ee
Mon Dec 29 20:15:12 CST 2003

Hi all,

Juz to add on more information on the problem.

Currently, I retrieved information from database into an
array. And I would like to store this value into a set of
checkboxes for users to select.

Below are my code. I have 3 different types of algorithms
but none work.


FOR i = 1 TO ALEN(arr)
thisform.fra1.AddObject(temp, "checkbox")
temp.caption = TRANSFORM(arr[i])
temp.autosize = .t.
temp.visible = .t.
ctrlarr[i] = temp
temp = .null.
NEXT



FOR i = 1 TO ALEN(arr)
ctrlarr[i] = CREATEOBJECT("checkbox")
ctrlarr[i].caption = TRANSFORM(arr[i])
ctrlarr[i].autosize = .t.
ctrlarr[i].visible = .t.
NEXT



FOR i = 1 TO ALEN(arr)
varname = TRANSFORM(ctrlarr[i])
thisform.fra1.NewObject(varname, "checkbox")
&ctrlarr[i].caption = TRANSFORM(arr[i])
&ctrlarr[i].autosize = .t.
&ctrlarr[i].visible = .t.
NEXT


Help!!!!!

Sigh....
>-----Original Message-----
>Hi all,
>
>I've recently started working on a project using
>microsoft visual foxpro 8.0. Unfortunately i met with
>some problems creating checkboxes wif values retrieved
>from a database table.
>
>Any help is appreciated.
>
>Thanks
>.
>

creating check boxes programmatically by Hidayat

Hidayat
Mon Dec 29 22:49:08 CST 2003

Hi Ee Shan,
I'm not sure, because you don't mention what the problem
accurately. However did you see the error message when the
form was running..? or did you see only 1(one) checkbox
appear on the form..?, try to put difference value into
properties (left, top) for each checkbox array.

Regards
Hidayat
>-----Original Message-----
>Hi all,
>
>Juz to add on more information on the problem.
>
>Currently, I retrieved information from database into an
>array. And I would like to store this value into a set of
>checkboxes for users to select.
>
>Below are my code. I have 3 different types of algorithms
>but none work.
>
>
> FOR i = 1 TO ALEN(arr)
> thisform.fra1.AddObject(temp, "checkbox")
> temp.caption = TRANSFORM(arr[i])
> temp.autosize = .t.
> temp.visible = .t.
> ctrlarr[i] = temp
> temp = .null.
> NEXT
>
>
>
> FOR i = 1 TO ALEN(arr)
> ctrlarr[i] = CREATEOBJECT("checkbox")
> ctrlarr[i].caption = TRANSFORM(arr[i])
> ctrlarr[i].autosize = .t.
> ctrlarr[i].visible = .t.
> NEXT
>
>
>
>FOR i = 1 TO ALEN(arr)
> varname = TRANSFORM(ctrlarr[i])
> thisform.fra1.NewObject(varname, "checkbox")
> &ctrlarr[i].caption = TRANSFORM(arr[i])
> &ctrlarr[i].autosize = .t.
> &ctrlarr[i].visible = .t.
>NEXT
>
>
>Help!!!!!
>
>Sigh....
>>-----Original Message-----
>>Hi all,
>>
>>I've recently started working on a project using
>>microsoft visual foxpro 8.0. Unfortunately i met with
>>some problems creating checkboxes wif values retrieved
>>from a database table.
>>
>>Any help is appreciated.
>>
>>Thanks
>>.
>>
>.
>

Re: creating check boxes programmatically by Trey

Trey
Mon Dec 29 22:53:49 CST 2003

Since it seems you'd like the control array to stay in scope, and you're
using vfp8, why not try a Collection class instead?
e.g. [swag code: don't have vfp8 at hand]

** assuming thisform.oChkCollection is a collection
** object that already exists

** this removal code may not be necessary...
Do While thisform.oChkCollection.Count>0
thisform.oChkCollection.Remove(1)
EndDo
**
For i = 1 to ALen(arr)
lcChk = "checkbox"+Transform(i)
thisform.fra1.AddObject(lcChk, "checkbox")
thisform.oChkCollection.Add(thisform.fra1.&lcChk)
thisform.oChkCollection(i).Caption=Transform(arr[i])
thisform.oChkCollection(i).AutoSize=.T.
thisform.oChkCollection(i).Visible=.T.
Next


HTH

"Ee Shan" <anonymous@discussions.microsoft.com> wrote in message
news:042f01c3ce7a$c16cf0a0$a501280a@phx.gbl...
> Hi all,
>
> Juz to add on more information on the problem.
>
> Currently, I retrieved information from database into an
> array. And I would like to store this value into a set of
> checkboxes for users to select.
>
> Below are my code. I have 3 different types of algorithms
> but none work.
>
>
> FOR i = 1 TO ALEN(arr)
> thisform.fra1.AddObject(temp, "checkbox")
> temp.caption = TRANSFORM(arr[i])
> temp.autosize = .t.
> temp.visible = .t.
> ctrlarr[i] = temp
> temp = .null.
> NEXT
>
>
>
> FOR i = 1 TO ALEN(arr)
> ctrlarr[i] = CREATEOBJECT("checkbox")
> ctrlarr[i].caption = TRANSFORM(arr[i])
> ctrlarr[i].autosize = .t.
> ctrlarr[i].visible = .t.
> NEXT
>
>
>
> FOR i = 1 TO ALEN(arr)
> varname = TRANSFORM(ctrlarr[i])
> thisform.fra1.NewObject(varname, "checkbox")
> &ctrlarr[i].caption = TRANSFORM(arr[i])
> &ctrlarr[i].autosize = .t.
> &ctrlarr[i].visible = .t.
> NEXT
>
>
> Help!!!!!
>
> Sigh....
> >-----Original Message-----
> >Hi all,
> >
> >I've recently started working on a project using
> >microsoft visual foxpro 8.0. Unfortunately i met with
> >some problems creating checkboxes wif values retrieved
> >from a database table.
> >
> >Any help is appreciated.
> >
> >Thanks
> >.
> >



Re: creating check boxes programmatically by Ee

Ee
Mon Dec 29 23:37:35 CST 2003

hi,
thx for ur reply...
however i still haf one problem, which is how to declare
the oChkCollection.

do i use local oChkCollection = new Collection()?

regards

>-----Original Message-----
>Since it seems you'd like the control array to stay in
scope, and you're
>using vfp8, why not try a Collection class instead?
>e.g. [swag code: don't have vfp8 at hand]
>
>** assuming thisform.oChkCollection is a collection
>** object that already exists
>
>** this removal code may not be necessary...
>Do While thisform.oChkCollection.Count>0
> thisform.oChkCollection.Remove(1)
>EndDo
>**
>For i = 1 to ALen(arr)
> lcChk = "checkbox"+Transform(i)
> thisform.fra1.AddObject(lcChk, "checkbox")
> thisform.oChkCollection.Add(thisform.fra1.&lcChk)
> thisform.oChkCollection(i).Caption=Transform(arr[i])
> thisform.oChkCollection(i).AutoSize=.T.
> thisform.oChkCollection(i).Visible=.T.
>Next
>
>
>HTH
>
>"Ee Shan" <anonymous@discussions.microsoft.com> wrote in
message
>news:042f01c3ce7a$c16cf0a0$a501280a@phx.gbl...
>> Hi all,
>>
>> Juz to add on more information on the problem.
>>
>> Currently, I retrieved information from database into
an
>> array. And I would like to store this value into a set
of
>> checkboxes for users to select.
>>
>> Below are my code. I have 3 different types of
algorithms
>> but none work.
>>
>>
>> FOR i = 1 TO ALEN(arr)
>> thisform.fra1.AddObject(temp, "checkbox")
>> temp.caption = TRANSFORM(arr[i])
>> temp.autosize = .t.
>> temp.visible = .t.
>> ctrlarr[i] = temp
>> temp = .null.
>> NEXT
>>
>>
>>
>> FOR i = 1 TO ALEN(arr)
>> ctrlarr[i] = CREATEOBJECT("checkbox")
>> ctrlarr[i].caption = TRANSFORM(arr[i])
>> ctrlarr[i].autosize = .t.
>> ctrlarr[i].visible = .t.
>> NEXT
>>
>>
>>
>> FOR i = 1 TO ALEN(arr)
>> varname = TRANSFORM(ctrlarr[i])
>> thisform.fra1.NewObject(varname, "checkbox")
>> &ctrlarr[i].caption = TRANSFORM(arr[i])
>> &ctrlarr[i].autosize = .t.
>> &ctrlarr[i].visible = .t.
>> NEXT
>>
>>
>> Help!!!!!
>>
>> Sigh....
>> >-----Original Message-----
>> >Hi all,
>> >
>> >I've recently started working on a project using
>> >microsoft visual foxpro 8.0. Unfortunately i met with
>> >some problems creating checkboxes wif values retrieved
>> >from a database table.
>> >
>> >Any help is appreciated.
>> >
>> >Thanks
>> >.
>> >
>
>
>.
>

Re: creating check boxes programmatically by Trey

Trey
Tue Dec 30 00:02:18 CST 2003

i'd try this in the form's init()

this.AddObject("oChkCollection", "collection")

"Ee Shan" <anonymous@discussions.microsoft.com> wrote in message
news:05dd01c3ce97$0733ba80$a601280a@phx.gbl...
> hi,
> thx for ur reply...
> however i still haf one problem, which is how to declare
> the oChkCollection.
>
> do i use local oChkCollection = new Collection()?
>
> regards
>
> >-----Original Message-----
> >Since it seems you'd like the control array to stay in
> scope, and you're
> >using vfp8, why not try a Collection class instead?
> >e.g. [swag code: don't have vfp8 at hand]
> >
> >** assuming thisform.oChkCollection is a collection
> >** object that already exists
> >
> >** this removal code may not be necessary...
> >Do While thisform.oChkCollection.Count>0
> > thisform.oChkCollection.Remove(1)
> >EndDo
> >**
> >For i = 1 to ALen(arr)
> > lcChk = "checkbox"+Transform(i)
> > thisform.fra1.AddObject(lcChk, "checkbox")
> > thisform.oChkCollection.Add(thisform.fra1.&lcChk)
> > thisform.oChkCollection(i).Caption=Transform(arr[i])
> > thisform.oChkCollection(i).AutoSize=.T.
> > thisform.oChkCollection(i).Visible=.T.
> >Next
> >
> >
> >HTH
> >
> >"Ee Shan" <anonymous@discussions.microsoft.com> wrote in
> message
> >news:042f01c3ce7a$c16cf0a0$a501280a@phx.gbl...
> >> Hi all,
> >>
> >> Juz to add on more information on the problem.
> >>
> >> Currently, I retrieved information from database into
> an
> >> array. And I would like to store this value into a set
> of
> >> checkboxes for users to select.
> >>
> >> Below are my code. I have 3 different types of
> algorithms
> >> but none work.
> >>
> >>
> >> FOR i = 1 TO ALEN(arr)
> >> thisform.fra1.AddObject(temp, "checkbox")
> >> temp.caption = TRANSFORM(arr[i])
> >> temp.autosize = .t.
> >> temp.visible = .t.
> >> ctrlarr[i] = temp
> >> temp = .null.
> >> NEXT
> >>
> >>
> >>
> >> FOR i = 1 TO ALEN(arr)
> >> ctrlarr[i] = CREATEOBJECT("checkbox")
> >> ctrlarr[i].caption = TRANSFORM(arr[i])
> >> ctrlarr[i].autosize = .t.
> >> ctrlarr[i].visible = .t.
> >> NEXT
> >>
> >>
> >>
> >> FOR i = 1 TO ALEN(arr)
> >> varname = TRANSFORM(ctrlarr[i])
> >> thisform.fra1.NewObject(varname, "checkbox")
> >> &ctrlarr[i].caption = TRANSFORM(arr[i])
> >> &ctrlarr[i].autosize = .t.
> >> &ctrlarr[i].visible = .t.
> >> NEXT
> >>
> >>
> >> Help!!!!!
> >>
> >> Sigh....
> >> >-----Original Message-----
> >> >Hi all,
> >> >
> >> >I've recently started working on a project using
> >> >microsoft visual foxpro 8.0. Unfortunately i met with
> >> >some problems creating checkboxes wif values retrieved
> >> >from a database table.
> >> >
> >> >Any help is appreciated.
> >> >
> >> >Thanks
> >> >.
> >> >
> >
> >
> >.
> >



Re: creating check boxes programmatically by Igor

Igor
Tue Dec 30 11:16:56 CST 2003

Hi, Ee Shan!
You wrote on Mon, 29 Dec 2003 18:15:12 -0800:

ES> Currently, I retrieved information from database into an
ES> array. And I would like to store this value into a set of
ES> checkboxes for users to select.

ES> Below are my code. I have 3 different types of algorithms
ES> but none work.

ES> FOR i = 1 TO ALEN(arr)

* I suggest that "fra1" is a kind of container,
* an object that MAY have another objects inside it :)
* For simplicity try first with the form itself - so
* throw away "fra1" from below code

* Construct unique name for new object.

temp = "chk" + TRANSFORM(m.i)

ES> thisform.fra1.AddObject(temp, "checkbox")

* now find out object reference to newly created object
* note that it is easier to read the code, if you'll use
* another name for object reference, say lcTemp for object name
* and loTemp for object reference itself, but it doesn't really matter

temp = EVAL("thisform.fra1." + m.temp)

ES> temp.caption = TRANSFORM(arr[i])
ES> temp.autosize = .t.
ES> temp.visible = .t.

m.temp.Top = m.i*20

* Otherwise all our checkboxes will sit one over another :)

ES> ctrlarr[i] = temp

* Remove previous line

ES> temp = .null.

* And this line is really of no sence if you'll
* use LOCAL variable "temp" (you really do the best if declare it
* as LOCAL - and of course outside the loop)

ES> NEXT

* For the next sample you have to have "ctrlarr"
* as a form propery (and as an array!) and you
* have to reference it in a corresponding way, like
* ThisForm.ctrlarr[i]

ES> FOR i = 1 TO ALEN(arr)
ES> ctrlarr[i] = CREATEOBJECT("checkbox")
ES> ctrlarr[i].caption = TRANSFORM(arr[i])
ES> ctrlarr[i].autosize = .t.
ES> ctrlarr[i].visible = .t.
ES> NEXT

* Sorry it is a kind of stuff no one can analyse :)
* Array of names, array of values %)
* be a bit simplier :)

ES> FOR i = 1 TO ALEN(arr)
ES> varname = TRANSFORM(ctrlarr[i])
ES> thisform.fra1.NewObject(varname, "checkbox")
ES> &ctrlarr[i].caption = TRANSFORM(arr[i])
ES> &ctrlarr[i].autosize = .t.
ES> &ctrlarr[i].visible = .t.
ES> NEXT

If you really want to have "control array" - google on this term in fox NGs
:) There will be a number of corresponding messages.

P.S. Happy New Year

--
WBR, Igor



Re: creating check boxes programmatically by Ee

Ee
Thu Jan 01 20:18:04 CST 2004

Thx 4 all u guys help....

Solved it already....

Thanks again and a Happy New Yr to all of u out there! =)