Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid Double Click
Message
From
06/02/2000 15:23:10
 
 
To
06/02/2000 12:53:53
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00327950
Message ID:
00328082
Views:
26
>>>ALternatively, you can create a textbox class that will become your grid textbox class, and swap out the base textbox for yours at runtime. The disadvantage to this is that it prevents you from putting instance code in your textboxes if you need to.
>>
>>You could use a textbox class that delegates events to the gridclass. Something like: grid.ColumnClick(this, columnNumber) You could go a step further and create an array property in the grid that contains references to objects that handle the delegated events. The nice thing about delegation to an object is that you can change what event handle object is referenced at will. This is a nice way of handling different behavior for different operating modes, it removes any need for case structures in the event handlers for multiple states.
>
>This is what I do most of the time, but you still have to have a textbox class that calls the grid's method, or you'll be writing that call in every box. And this still only lets you write common code for all textboxes in the grid, so if each one needs different behavior, you're writing a CASE statement to look at the calling object... this is not a nice way of handling it, but maybe the best design compromise.

If you reread my statement above, you will note that I addressed the case structure issue and provided a way to avoid it. A refinement of the above technique would be to add the event handler object to the column instead of to the grid array property.

Grid::Init()

dodefault()
with this
.Column1.RemoveObject("Text1")
.Column1.AddObject("Text1", "EventDelegatingTextBox")
.Column1.AddObject("Text1EventHandler", "EventDelegatingTextBox")
.CurrentControl = "Text1"
endwith


When a state change dictates different event handling behavior...
Grid::ChangeOperatingMode()

with this
.Column1.RemoveObject("Text1EventHandler")
.Column1.AddObject("Text1EventHandler", "AlternateEventDelegatingTextBox")
endwith


EventDelegatingTextBox::XXXEvent()

=evaluate("this.parent." + this.Name + "EventHandler.XXXEvent(this)")

or

return evaluate("this.parent." + this.Name + "EventHandler.XXXEvent(this)") && if the event has a return value

Alternately, if the Column acts as the event handler...

this.parent.EventHandler.XXXEvent(this)

or

return this.parent.EventHandler.XXXEvent(this) && if the event has a return value
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform