Container control with events of listbox object

I have an Container Control CLASS with several controls, one of them is a listbox.
When subclass this Container control i want to use an event of the listbox, cell click.
How can i achieve this.
The events on the Container Control does not has the event CellClick?
an for that particualr instance i have an different method for cell click?


Create an event definition on the Container Control, then in the CellClick event of the Listbox on the container raise the Event Definition you created. The instance of that container will now perform the event when CellClick happens.

Thanks, can i also write some code in the event definition?

You write it in the ‘subclass’.

If by subclass you mean an instance placed on a window then that’s the normal way. If you mean a subclass of your custom ContainerControl, I didn’t know that could be done but just tried it and it works.

writing code in an event def ?
it better not

If this is towards me I mean the event handler of a subclass of a custom ContainerControl where the event def was added.

the original answer wasn’t clear this is what you meant so it sounded like you just tried writing code in the event definition itself and “this worked”
yes you can implement the event in the subclass - why wouldn’t you be able to ?

I didn’t know you can subclass a customized ContainerControl. I thought once you laid out a CC that it was ‘terminal’ and not valid to subclass it.

Your ContainerControl name is Ruud_CC,
Your embeded Listbox (in Ruud_CC) name is LB,

In the navigator, select Ruud_CC, then LB, then Add CellClick Event,

Then, in the CellClick Event, add your code.

To access your LB Listbox from the Ruud_CC ContainerControl, use Ruud_CC.LB.<Method|Property|whatever>.

When done, move Ruud_CC to your window. In that window, you can access to the Ruud_CC.LB (Listbox), use… [code]Ruud_CC1.LB./code]

Is this clear ?

You can’t. You get an error when you try to run it.

No, I ran my test and got the Msgbox.

Let me try it again to confirm…

Create ContainerControl CC1 like this

[code]ContainerControl CC1

Event CCCellClick() //new event definition

Control lb As Listbox
Sub Open()
me.AddRow “foo” //so there’s something to click
End Sub
Function CellClick(row as Integer, column as Integer, x as Integer, y as Integer) as Boolean
RaiseEvent CCCellClick
End Function
End Control

End ContainerControl[/code]

Then create a Class, set its super to CC1, and implement the event

[code]Class Class1 Inherits CC1

Sub CCCellClick()
MsgBox “ok”
End Sub

End Class[/code]

drop Class1 on a Window, size it out because it doesn’t respect the CC size. run, click and I get “ok”.