Is It Possible To Add Click Events To An Icon Within A ListView Tile?

257 views Asked by At

I have overridden the draw event of a list view to draw my own individual tiles. On each tile I want to place an icon of a phone and attach a click event to it so a user can click on the little icon (within a tiled listview item) and it executes a command.

I'd also like to implement a hover type scenario where I can change icon colours or text colour when the mouse hovers over an icon.

Does anyone know if this is possible?

I am using the ObjectListView in tile view if that makes any difference.

1

There are 1 answers

2
Grammarian On

I guess you are using ObjectListView's ItemRenderer to custom draw the tiles.

Each renderer has a HitTest() method. In your renderer, override this method and when the given point is over something interesting, change the OlvListViewHitTestInfo.HitTestLocation to be UserDefined and OlvListViewHitTestInfo.UserData to be whatever you want (e.g. "phone").

ObjectListView.MouseMoveHitTest holds the hit test information from the last mouse move.

Setup a MouseUp event handler, and in that handler, look at MouseMoveHitTest.HitTestLocation and MouseMoveHitTest.UserData properties to see if the mouse was over your phone when it was clicked.

Similarly, when you are drawing your tile, you can use those same properties to decide whether to draw the phone highlighted or not.