Monday, February 04, 2008

Add Excel "Comment" Indicator to a DataGridView Cell

Geeky Storytelling - Mimickin' Excel Comments in the DataGridView

"I had a need to make the WinForm DataGridView bend to my will by having some Excel-like behavior. Since I had do do some digging to make this happen, thought I'd share.

First off, my goal was to include those little comment indicator triangles in specific cells. In order to do this, you need to handle the the CellPainting event. And no - before you ask - I haven't yet created my own grid control to inherit and extend the grid behavior...but it is on my list of refactoring tasks to consider.

image

Here is the CellPainting event handler (for simplicity, I'm always showing the little glyph. In reality, I selectively show it based on the data for the row):

..."

I just thought of a cool usage for this this weekend, so I wanted to make sure I blogged about it before I forgot it.

Unfortunately I've already forgotten it... sigh...  stupid old brain. I need a brain v2 upgrade.

Anyway, I can at least blog about the inspiration for the idea. The above post shows how you can add an Excel like comment indicator to a DataGridView cell.

No comments: