Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create a TextBox in code at runtime form a button
Message
From
19/09/1997 10:16:51
 
 
To
19/09/1997 10:04:36
Frank Shaw
Runestones Development Corporation
Ipswich, Massachusetts, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00050429
Message ID:
00050711
Views:
32
>>>I want to create a textbox in code from a command button use the textbox to enter so text and then destory the
>>>text box after I am done with it. I want to know If it is posiable to do this in visual foxpro 5.0a. If so what would the code look like to do it? I do realize that I could create the text box at design time and play with the
>>>visiable properity. But I want to create the textbox at runtime not design time.
>>>
>>>
>>>Frank H. Shaw
>>>fshaw@runestones.com
>>
>>**** cmd Click event
>>thisform.addobject("text12","textbox")
>>with thisform.text12
>> .left=5
>> .width=100
>> .top=15
>> .visible=.t.
>>endwith
>>**** another cmd Click event
>>thisform.removeobject("text12")
>
>
>Edward Pikman I created this code but it will not work can you tell me what is wrong with the code. I am geting syntax errors trying to get out of the editor.
>
>
>
>
>if !(plEdit_Flag)
> plEdit_Flag = .T.
> && We need to create on this form a textbox that we can use to type in the name
> && of the company because we do not want to type the name directly into the combobox
>
>
> ThisForm.cntbizcompany.ADDOBJECT("txtEditCompany","textbox")
>
> thisform.cntbizcompany.txteditcompany.FontSize = 9
> thisform.cntbizcompany.txteditCompany.height = 22
> thisform.cntbizcompany.txteditCompany.left = 228
> thisform.cntbizcompany.txteditCompany.top = 7
> thisform.cntbizcompany.txteditCompany.visible = .T.
> thisform.cntbizcompany.txteditCompany.width = 301
> thisform.cntbizcompany.txteditCompany.name = "txtEditCompany"
>
>
> thisform.cmdeditcompany_name.caption = "Remove"
>
>
> DEFINE CLASS mytextbox AS txtEditCompany
>
> PROCEDURE keypress
> LPARAMETERS nKeyCode, nShiftAltCtrl
>
> if nKeyCode = 13
>
> Set Step On
>
> Endif
>
> ENDPROC
>
> ENDDEFINE
>
>else
> && plEdit_Flag True
> && We need to remove the textbox from this form
>
> ThisForm.cntbizCompany.RemoveObject("txtEditCompany")
> plEdit_Flag = .F.
>
> thisform.cmdeditcompany_name.caption = "Edit"
>
>
>Endif
>

Editor is smart enough to highlight line with supposed syntax error. BTW, if you want to derive texbox from txtEditcompany class you should
ThisForm.cntbizcompany.ADDOBJECT("txtEditCompany","txtEditCompany")
Also it's good idea to use WITH/ENDWITH and create class using class designer.
Edward Pikman
Independent Consultant
Previous
Reply
Map
View

Click here to load this message in the networking platform