Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding code to events programmatically
Message
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 7
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01631115
Message ID:
01631583
Views:
84
That's what BINDEVENTS() is supposed to solve for you. You need to take another look at it because you can most definitely hook any events that way at runtime. In fact BINDEVENTS() is pretty damn flexible in that it can hook control events as well as plain methods which is quite powerful to implement functional style programming behavior in FoxPro.

The other alternative is to create a subclass of your listbox, add your event code then instantiate that class that has the code in it. If that doesn't work you ARE doing runtime event binding and you HAVE TO use BINDEVENTS() as that's the only way to attach behavior to an object.

+++ Rick ---

>I use the form designer always, but I have come across a situation where I need to add a listbox to a form programmatically. This I got right, and it pops up at the right time, etc, but I need help in where, and how to add the events code. This lot pops up the box. Where in relation to this do I put the events code? Many thanks!
>
>
>			thisform.AddObject('oList1','ListBox')
>			with thisform.oList1
>			   .rowSource = "oldjobs"
>			   .rowsourcetype=2
>			   .visible=.t.
>			   .top=186
>			   .left=350
>			   .width=250
>			   .columncount=2
>			   .columnwidths='150,75'
>			   .SelectedItemBackColor=RGB(70,60,50)
>			   .SelectedItemForeColor=RGB(10,191,160)
>			   .SpecialEffect=1
>			   .ItemBackColor=RGB(40,40,40)
>			   .ItemForeColor=RGB(255,204,153)
>			   .BorderStyle = 1
>			   .BorderColor=RGB(235,132,0)
>			endwith
>
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform