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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating click events programatically

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
I have set up a simple app to read the sub directories of a main directory and then populate a command set with the captions showing the names of the directories.

How do I create a click event assignment for each directory?

I need to issue a 'set default to' command to the directory in the caption value but I am stumped - could someone please give me a pointer or 2.

Keith
 
One way would be to use your own command button's class with the click event pre-coded.

Another way (VFP8 and up) would be to use BINDEVENT function and bind button's click to form's HandleClick method, for example.
 
If you mean a command group with a command set, this has memberclass/memberclasslibrary properties, which you can point to a command button class with a predefined click event.

And that click event could be as simple as
Code:
CD (this.caption)

Bye, Olaf.
 
Thanks markros and Olaf
I already have a click event associated with the button caption which does the same function for each button but with a different name but I was thinking about a case where I needed to prform a specific function for only one of the options.

I suspect I am not explaining this very well.

Keith
 
Keith,

I'm not sure what you are trying to do. What do you mean by a command set? And what do you mean about associating an event with a button caption?

It sounds like you have a group of command buttons, and you want to perform a certain action in each button's click, with a small variation each time. Is that right?

If so, create a separate class for the button. Give it a custom property that contains the variable information. For example, if the action you want to perform is SET DEFAULT TO, and the variable information is the target directory, you would place the directory name in the custom property.

In the click event, write code similar to the following:

SET DEFAULT TO (THIS.cDirectory)

where cDirectory is the property in question.

Then, at run time, programatically set the value of cDirectory in each case.

Does this help at all? If not, you need to explain more clearly what you are trying to do.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
auiopro, I think you don't understand the principle of the memberclass. ONce you set this and change the buttoncount, the buttons generated all have this class. So you only need one class with one code and not program each click event individual. I assume this IS what you want, and you get it be the member class.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top