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.
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.
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 ?
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”.