Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Rename form object at run-time while form is in use?
Message
 
 
À
28/08/2001 12:10:39
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00549854
Message ID:
00549908
Vues:
17
Hi!

I understand that this works in a simple sample. However, I have also experiense. Once I met that problem and it was related to the internal events pending for some VFP object. When I tried to rename or remove that object and add new object with the same name, I get the error that object already exist no matter what I do, even when at that moment object does NOT exist and debugger tools display that very clear. The problem was very hard to reproduce, but luckily it went away as soon as I make object invisible before removing - it seems all internal events are cleared for object when it is go to invisible mode. So, to be sure, I alway make object invisible before removing it, specially if its name used another time in the same code snippet by anotehr object. I also pretty beleive that extensive use of removeobject/addobject without this preventive thing could cause crashes, but I have no approvement. Just a recommendation to do this to be sure it works reliable way.



>Vlad,
>I didn't get 2nd step. You could just do plain renaming as far as you keep names unique. ie:
>
with thisform.SomeContainer
> .txt1.Name = 'txt3'
> .txt2.Name = 'txt1'
> .addobject('txt2','textbox')
>endwith
Is legal.
>Cetin
>
>>Hi!
>>
>>Is it not that easy to put all these controls into 2 containers. So when you need to use one set of controls, you just rename only one object - the container?
>>
>>The renaming algorithm should be following:
>>
>>1. Lock the scread if it is not already locked.
>>2. Make both containers (or sets of controls) not visible by setting their Visible property to .F. This is required, because VFP will not allow to rename the "Text3" to "Text1" when "Text1" just was here on form and just renamed to something else in the same code snippet. "Text1" will still be on the form as soon as it is visible even when you rename it disalowing to add anotehr object with similar name.
>>3. Change name of the main set of controls used for work to something predefined temporary, say, TXT_TEMPTEXT*.
>>4. Change the txtTextBox* for not shown controls set to required names.
>>5. Change the temporary names to the names that were before for not shown set.
>>6. Make controls visible.
>>7. Unlock the screen if it was locked in this procedure
>>
>>HTH.
>>
>>>I have a form with a bunch of textboxes layed-out kind of like a spreadsheet. Don't ask me why they didn't use a grid. I am modifying an existing form.
>>>
>>>On my form I have for example -
>>>
>>>Name = txtMyTextbox1, ControlSource = Person1
>>>Name = txtMyTextbox2, ControlSource = Person2
>>>
>>>And a command button -
>>>THISFORM.txtMyTextbox1.ControlSource = Person1
>>>THISFORM.txtMyTextbox2.ControlSource = Person2
>>>THISFORM.Refresh
>>>
>>>What I want to do is have another command button that does the following -
>>>THISFORM.txtMyTextbox3.ControlSource = Person3
>>>THISFORM.txtMyTextbox4.ControlSource = Person4
>>>THISFORM.Refresh
>>>
>>>But I want to rename txtMyTextbox1 to txtMyTextbox3 and also rename the ControlSource from Person1 to Person3. Like-wise for txtMyTextbox2. How can you rename the name of the objects when the form is already displayed using the command buttons to switch the objects names back and forth between two different sets of names?
>>>
>>>TIA!!!
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform