Information générale
Catégorie:
Codage, syntaxe et commandes
Create a button class that have the code you want in the Click() event. In your code, use this clas instead of the default one:
ThisForm.NewObject(cmdbutton, "MyCmdButton", "MyClassLib")
HTH
>I have been able to programmatically (init within a form) create and display command buttons from table data with the following suggested code:
>
>table ttype
>lncount = 0
>lnaddcount = 0
>lntop = 4
>lnleft = 20
>scan
> lncount = lncount + 1
> lnaddcount = lnaddcount + 1
> cmdbutton = 'cmdprod' + alltrim(str(lnaddcount))
> thisform.Addobject(cmdbutton, "Commandbutton")
> with eval("thisform." + cmdbutton)
> .visible = .t.
> .caption = alltrim(ttype.type)
> .top = lntop
> .height = 5
> .left = lnleft
> .width = 25
> endwith
> if lncount = 4
> lncount = 0
> lntop = lntop + 7
> lnleft = 20
> else
> lnleft = lnleft + 35
> endif
>endscan
>
>The buttons display on the form, but I have not been able to successfully assign a click procedure to each button. Clicking on a button does nothing.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement