views:

79

answers:

1

I'm trying to create a DataGridView cell class which hosts a control (all the time, not just while editing). So far, my approach has been to add the control to the grid and try to synchronise its position with that of the cell.

Would it be possible instead to keep the cell offscreen, route mouse and keyboard events to it, and paint it onto the cell?

UPDATE: By 'offscreen', I don't mean that it should be added to another control such that it isn't displayed; I mean that it should never be added to another control at all.

A: 

You can create a control without adding it to the form, then using it as the Cell editor whenever you need to. Usually with grids, when you click on a cell to edit it, it's going to either create a new control and put it in the right place, or it's going to use an existing control. You can make this process a lot easier by creating your own custom cell / column types. See this MSDN page: http://msdn.microsoft.com/en-us/library/7fb61s43.aspx.

Most grids (including DataGridView and 3rd Party Grids) have a facility for adding custom cells.

Garo Yeriazarian
I'm not interested in using it as the editing control - I want to use the control in place of the cell all the time.
Simon
So it's a single cell that has this control floating on it the whole time? Or is it a whole column of cells?
Garo Yeriazarian