Adding events to Grid Containers

I was trying to add a control to a desktop grid control and got stuck.

I took the desktop with three controls grid and tried to add and event to the tracklist listbox, such that when the track is selected the window would know and be able to launch a player… However I was able to add the listbox select handler, and define an event definition but when I got to the gid control and try to add an event handler to it.. i do not see the event I defined.

Hi @Brian_O_Brien

May you post some example code/link to download project showing what are you trying to do (and how)?

I am using the DesktopGrid Example with three controls.

Not sure how to bind events in the opening or if it is best

DesktopGrid with Three Containers.zip (422.1 KB)

The grid manager has a constructor and perhaps i can pass a delegate method to it to act as an async call back. (Thread safe?)

Playing audio is global. Why not to just create a global audio playing module and communicate directly with that from the Listbox SelectionChanged event?

Add and Remove handler can be tricky to use correctly, so Norman always said to avoid them if you can.

It’s possible, but the example design you’ve been following doesn’t make it easy.

It seems like everything in the grid has to manage itself.
So probably that is where things should go. (The gridManager)

Perhaps passing a delegate to the TracksContainer to such that the manager can ‘do something’.

That’s up to you. I recommend the much simpler route of a global audio module for this purpose.

Really this is just about learning how to use the control as it was designed.
I needed this grid because my window redraw logic was never right and this container really simplifies resize / resized event handling and layout…
I created a subclass of DesktopGrig called MyGrid with one event definition with a variant as a parameter… When the grid wants to send a message to the window it uses raises this event.

The control in the grid needs to ‘link’ to it’s parent.. and that is where is lose it.

Maybe you’ll want to take a look to the “DesktopGrid With Database” example project. That one uses a Delegate so the Containers can call it to update their values to the backing data source (the class acting as the Manager for the Grid Control).

If everything you want to do is acting on actions the user does on the controls added to the ContainerControl acting as a cell of the Grid… maybe you may want to add the corresponding events to the controls themselves…

1 Like