How to create custom DataGridViewCell

I am working on a grid view that will display cells that will contain some controls. For example, a cell will have three or four labels and possibly a set of colors. The values ​​of these labels can be linked to the database.

I am guessing that I need to create a custom DataGridViewCell, but I am having a hard time finding documentation that talks about this type of custom cell. Most examples show how to extend a DataGridViewCell with other DataGridViewCell types such as DataGridViewImageCell.

Does anyone have an example of a custom cell class that comes from a DataGridViewCell?

Here is my awful attempt at trying to paint this cell in paint.Net. Hopefully after you laugh, you get an idea of ​​the custom cell I'm trying to build. alt text http://lh3.ggpht.com/_UxHcYyy8tU8/SgmTd1MqUOI/AAAAAAAAAnU/lO2bE7-gvpg/s800/DataGridViewCell.png

+1


a source to share


2 answers


I thought about this more and I found that my approach was wrong. The DataGridView has good support for adding custom controls in edit mode, but the view it creates is intended to be always interactive and is probably not suitable for the DataGridView.

The solution I came across was to use a TableLayoutPanel. This control works great for me because you have so much control over its rendering and it is very easy to insert controls into it.



Perhaps the question I asked needs to be tweaked a bit, because the solution, excluding me, solves my problem, but doesn't really answer the question.

+2


a source


If the socket layout of the cell is static, placing a custom control in the cell might be appropriate.



+1


a source







All Articles