views:

26

answers:

1

Is this possible to have two (or more) different kinds of cells to be displayed interchangeably in single column of C# .Net 3.5 WinForms DataGridView?

I know one column has specified single EditingControl type, yet I think grid is flexible enough to do some tricks, I may think of only:

  • Adding as many invisible columns to grid as required types of cells and on CellBeginEdit somehow exchange current cell with other column's cell

  • Creating custom column and custom cell with possibility of changing EditingControl for single cell

Which approach is better, is there any other solution, are there any examples ?

+1  A: 

I would just create the custom column and cell (your second solution). Then override the render method of the cell and have it spit out the html depending on what you need. Your first option of swapping cells sounds like it could quickly lead to bugs. Not to mention that every cell would need knowledge of several different columns which in itself would be complicated.

Peter
I am looking for solution for WinForms DataGridView, yet looks like this approach also fits ASP grid.
too
Ah, yes, sorry about that. My point still stands though - just without the html part...
Peter