Custom (User Control?) DataGridView column

A

Adam Clauss

I'm looking for a way to embed some content somewhat more complicated than
the basic columns provide. The way I "envisioned" it working was defining a
UserControl that defined what the cell content should be and being able to
place that UserControl into the cell.

Google searches did not really show an example of this, but it did lead me
to:
http://msdn.microsoft.com/en-us/library/ms180996.aspx

But... that sample is almost "cheating" - it is simply deriving from the
existing DataGridViewTextBoxCell and giving it some slightly special
behavior to do the masking. It is NOT truly a "custom column".

My next guess was to open up reflector and take a look at how the built-in
column types (checkbox, textbox, etc) were actually implemented. I was
hoping to find a textbox control, or a checkbox control somewhere under the
scenes and be able to more-or-less replace that with my user control for my
custom column. No such luck - it seems those columns types are actually
owner-drawing the content, and not using the existing controls to handle
things.

Owner drawing is not completely out of the question, especially since the
content is read-only, but it would be MUCH simpler to be able to 'design'
things on the user control to be placed into the cell.

Am I missing something? Is there a good way to do this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top