Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding cmdbuttons programatically
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01321009
Message ID:
01321043
Views:
16
>>>I was playing around trying to add a whole bunch commandbuttons on a form I made in the designer but it executes and I see no commandbuttons. Are they invisible?
>>>
>>>FOR i = 1 TO 80
>>>c='cmd'+ALLTRIM(STR(i))
>>>thisform.AddObject(m.c,'commandbutton')
>>with evaluate('thisform.' + m.c)
>>   .visible = .t.
>> && you also need to set top and left properties
>>endwith
>>>next
>>
>>Yes, you need to explicitly set visible property to true. See changes inside.
>
>How would I go about positioning them?


Something like (Starting from (0,0) and have 3 buttons at a row:
lnTop = 0
lnLeft = 0
FOR i = 1 TO 80
    lcButtonName = 'cmd'+ALLTRIM(STR(i))
    thisform.AddObject(m.lcButtonName,'commandbutton')
    with evaluate('thisform.' + m.c)
         .Top     = m.lnTop
         .Left    = m.lnLeft
         IF i % 3 == 0
            lnTop  = lnTop + .Height + 1
            lnLeft = 0
         ELSE
            lnLeft = lnLeft + .Width + 2
         ENDIF
         .visible = .t.
    endwith
next
Not tested :-)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform