开发者

Event handling for dynamic array of controls

I found this link to handle events for a dynamically created control in VB6 and I tried to use this for my code, but to no avail.

Option Explici开发者_Go百科t  
Private WithEvents grid(0 To 23, 0 To 23) As Frame  

How can I get the same functionality for this array of controls?


You can't.

You can either use control arrays where you Load new indexes (instances) of your control or write a custom wrapper class that forwards the events through callback methods.

For second option:

  • you have a class cFrameExt that sinks Frame's events
  • on event it calls a callback method on a "parent" object
    • passing me as first parameter
  • "parent" substitutes me with an integer index and raises an event

Most problematic is cyclic references this scheme is usually implemented with.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜