how add a button into a grid

Hi, I need add a button to a grid. Maybe I need use the customer
render/editor, but I still a question, how handle the button event,
because the button is drawn in the render using dc and can not add the
event hander.

please help me.

hansir wrote:

Hi, I need add a button to a grid. Maybe I need use the customer
render/editor, but I still a question, how handle the button event,
because the button is drawn in the render using dc and can not add the
event hander.

The grid is designed to use the cell editors to manage the widgets that will be used to edit cell contents. There can only be one active editor (and therefore one active widget) at a time, so all other cells must be able to draw something to represent the value of the cell (the renderer does this.) So yes, to do this the way the grid was designed you'll need to have a renderer that draws something that looks like a button and an editor that creates a button and handles its events. To answer your question, you can have the editor object catch the button's event, and then it can call something else in your app if needed.

The other way to do this would be to bypass the grid and manage the size and layout of the buttons yourself, then you could have all the buttons present all the time, not just a drawing that looks like a button. I expect that this will get fairly hard to do however, once the grid starts scrolling.

···

--
Robin Dunn
Software Craftsman