I appreciate your help with all of this. In the end, I did have to write seperate event subs (double click) for each linklabel, but it wasn't that simple.
The labels were created within a loop.
(1) If I included
LLDblClick.New1(Control("Label" & i,"LinkLabel").Control,"DoubleClick")
within the loop, all labels get wired to the same sub (LLDblClick_NewEvent). It works just fine in the IDE, but when compiled only the last control activates the double click event.
(2) My first solution was to have separate subs and include
AddObject("LLDblClick" & i,"Event")
within the loop, and outside the loop have a series of lines:
LLDblClick1.New1(Control("Label1","LinkLabel").Con trol,"DoubleClick")
LLDblClick2.New1(Control("Label2","LinkLabel").Con trol,"DoubleClick")
etc. This works fine in the IDE, but when attempting to compile, I get an error "Unknown control type. Use Control("_main_lldblclick1,Type) instead."
(3) Leaving these lines alone, I deleted the AddObject within the loop and created the series of objects using the Tools menu. Doing this, the code works both in the IDE and when compiled.
Attached are examples of the three versions.
Also you will note the empty LLclick subroutine. If the single click event is not created, when compiled I get an "Unhandled exception" error when a label is clicked.
So, in the end my code is ugly and with 42 linklables quite tedious, but at least I can move on to something else. Thanks for the experience.
but when compiled only the last control activates the double click event.
That is the behaviour I would expect because you are reusing the same event object each time. On NEW it should be disposed and recreated. That looks a bit like a bug in IDE, I'll point Erel at it.
Quote:
LLDblClick1.New1(Control("Label1","LinkLabel").Con trol,"DoubleClick")
etc. This works fine in the IDE, but when attempting to compile, I get an error "Unknown control type. Use Control("_main_lldblclick1,Type) instead."
I think it is telling you to use this
Control("Main.LLDblClick1", "Event").New1(Control("Label1", "LinkLabel").Control,"DoubleClick")
You could probably put this in the loop using Main.LLDblClick & i. I haven't checked this code fragment so there may be errors but you get the idea.
Quote:
If the single click event is not created, when compiled I get an "Unhandled exception" error when a label is clicked.
That's a bug in LinkLabel (which I didn't write )
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Objects in the IDE are not being disposed implicitly due to the way the IDE holds references to objects.
Explicitly disposing the object will prevent this discrepancy.
Code:
Sub App_Start
For i = 1To3 AddObject("Label" & i,"LinkLabel") Control("Label" & i,"LinkLabel").New1("Form1",35,45*i,33,33) Control("Label" & i,"LinkLabel").BackColor = cWhite Control("Label" & i,"LinkLabel").fontsize = 6 Control("Label" & i,"LinkLabel").text = "Lbl " & i Control("Label" & i,"LinkLabel").underline = False AddEvent ("Label" & i,Click,"LLclick") If i > 1Then LLDblClick.Dispose AddObject("LLDblClick","Event") LLDblClick.New1(Control("Label" & i,"LinkLabel").Control,"DoubleClick") Next i
Form1.Show End Sub
You need to add an Event object for each event:
Code:
Sub App_Start
For i = 1To3 AddObject("Label" & i,"LinkLabel") Control("Label" & i,"LinkLabel").New1("Form1",35,45*i,33,33) Control("Label" & i,"LinkLabel").BackColor = cWhite Control("Label" & i,"LinkLabel").fontsize = 6 Control("Label" & i,"LinkLabel").text = "Lbl " & i Control("Label" & i,"LinkLabel").underline = False AddEvent ("Label" & i,Click,"LLclick") AddObject("LLDblClick" & i,"Event") Control("LLDblClick" & i, Event).New1(Control("Label" & i,"LinkLabel").Control,"DoubleClick") AddEvent("LLDblClick" & i, NewEvent, "LLDblClick_NewEvent") Next i
Form1.Show End Sub
We plan to add a simpler syntax for runtime controls/objects which will make it simpler as it will allow the IDE to show the list of properties and methods for these objects as well.
I will describe the new syntax with following example:
Control("tree" & i, TreeView).Node will be equal to:
TreeView("tree" & i).Node