Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On VFP6, how to display label number when clicked when more than one 2

Status
Not open for further replies.

VictorFRodriguez

Programmer
Jan 20, 2001
51
DO
I have a form that launches more than 40 labels when initiating. Each label has the name of the label number. I need to display the name of the label in a text box when one of those labels is clicked. It has to be on VP6. Any solution?
 
In the click event of the label put:

[pre]thisform.text1.value = this.Caption [/pre]

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I would say [tt]thisform.text1.value = this.name[/tt], but Mike's idea remains.

It's, of course, easier if all the labeös are your derived class instead of the base label class. If you use the base label class you need to go into all 40 click events and add that line of code.
Since Bindevents() also is forbidden the only comfortable way to do that is using the form as a table and changing the code in the data it actually is.

I don't know what you mean by "launch", though. Your form either already has 40 labels or you create them add runtime, thisform.addobject(). Launching is a word I'd only use in conjunction with starting (launching) a new form. If you create 40 labels you can, of course, create a class of the label having that line of code in its click. As the code doesn't change for each label you only need to design that class once.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Olaf Dosschke seems to be the more ideal. Because the 40 labels might change further for 50 or any number. The only problem with me is that I do not know how to " create a class of the label having that line of code in its click. As the code doesn't change for each label you only need to design that class once." Could you teach me how? or show me an example?
 
Create a class:

In the project manager click on the classes tab, click new. As classname enter mylabel. For "based on" pick label. For "store in" enter a file name, this will be a vcx file.
Now in the class designer change to the click event. The simplest way is to double click, you get to the code editor. Look at the header, it tells you which method or event of the object you edit. Now enter the code: [tt]thisform.text1.value = this.name[/tt]

Now you can save this.

To put this on a form you can visually drag it from the vcx onto the form, you can write code that does a loop [tt]FOR i = 1 to 40[/tt] and adds 40 labels [tt]thisform.addobject("label"+transform(i),"mylabel")[/tt] once you did SET CLASSLIB TO the vcx file. Of course, also set their positions, etc. and finally set them .visible = .t., but I want to concentrate on how to create the class.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Olaf, Thanks a lot. You have been of great help to me. I did what you wrote and worked perfectly! You are pushing me to continue asking more questions in this forum.
For this case,I did not find the class manager in the VFP6 menu. But I used the command windows with the statement MODIFY CLASS mylabel and continued doing the class. When inserting the class to the form, I did used the VFP6 menu FORM and then INCLUDE FILE, selected ALL and, at last.... everything working good.
Thanks again.
 
I think you meant project manager.

To have all files belonging to an EXE under one roof. What you should start with is CREATE PROJECT.. Give it a try. It organizes all your files used together to build an executable.

Bye, Olaf.

Olaf Doschke Software Engineering
 
I did not find the class manager in the VFP6 menu

There is no class manager. What Olaf was referring to was the project manager. You open the project manager from the File menu (assuming the project already exists). Then go to the Classes tab and click New.

But never mind. You found how to achieve the same objective from the command window, which is fine. (In fact, that's what I normally do.)

You say Olaf has been a great help to you. Did you know that Tek Tips has a feature that lets you flag a post as being particularly helpful? Just click the "Great post" link at the bottom right of the post in question. This will flag the post with a star, which is useful as it will let other forum visitors see at a glance which questions have been answered and which posts have been the most useful.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top