[quote=48672:@Glen Newbury]Hi, I’m very new to Xojo.
I’d like to centralize all my event handler code for a list box in a class.
[/quote]
What you probably want to do is create a subclass of Listbox that has all your common code then use instances of that on your window layouts
To add to Norman’s answer, you also want to define a custom event in your subclass for CellBackgroundPaint (g As Graphics, Row As Integer, Column As Integer) As Boolean, then modify your custom code slightly:
if CellBackgroundPaint( g, Row, Column) then return true // The subclass handled it
// Highlight ever other row
If row Mod 2 = 0 And AlternateHighlightCheckBox.Value Then
g.ForeColor = &cf3f6fA
g.FillRect(0, 0, g.Width, g.Height)
End If
return true
When you add your ListBox subclass to your windows, there will still be a CellBackgroundPaint event, and if you return true from those, the subclass code won’t fire.