Monday, August 29, 2005

DataGridView Rich Text Column

A lot of applications need to display formatted text in a table. Out of the box the DataGridView only supports a TextBox column type for which the formatting options are quite limited. As the cells within a DataGridView are no standard user controls it is no trivial task to implement. I implemented a RichTextBox column type based on the following Microsoft knowledge base article:

     Print the Content of a RichTextBox

This article shows how to render the RichTextBox content on a printer device context using the EM_FORMATRANGE message. Instead of the printer I let this code render the content on a device context for a Bitmap:

    Image LimgImage = ...
    Graphics LobjGraphics = Graphics.FromImage(LimgImage);
    IntPtr LobjHdc = LobjGraphics.GetHdc();

This image is then rendered in the Paint event of the cell.

In my application it was furthermore necessary to edit the content in the cells. For this I used the default RichTextBox. It required quite some time to get the sizing right so the image rendered in display mode exactly fitted the content of the RichTextBox used to enter the content, but at the end all the magic numbers involved were :-)

Comments:
Hi Jurgen,

What you have done here is exactly what i am trying to do. If you can share the code, please email it to me at danielcor at gmail.com

Thanks in advance!

- Daniel
 
Hi Jurgen,
i'm also interested in your implementation of the Rich Text Column.

Would be possible to get the source code.
Contact me at rodrigo@tekchile.cl
 
Hi Jurgen,
i'm also interested in your implementation of the Rich Text Column.

Would be possible to get the source code.
Contact me at weinhold.d@datacomm.ch
 
Hi Jurgen,
I'm interested also in what you have done. Perhaps you could post your code on your blog, or email it mmacrobert at gmail dot com.
Thanks,
Martin
 
Hi Jurgen,

i'm also interested in your implementation of the Rich Text Column for the DataGridView.

If you can share the code, please email it to me at bernd_es3@web.de

Thanks, Bernd
 
Hi Jurgen,
I'd also be very interested in this, can you post this to your blog? Or e-mail me at jason at palmernjdotcom?

Thanks in advance!

-Jason
 
Hi Jurgen,

Even I am interested in doing this in my application. can you email the code to pmeka@gmail.com please?

thanks in advance.
 
Hi Jurgen,

I am looking for similar type of implementation. Please share me the code of "DataGridView Rich Text Column". It will be very much helpful to me.

Thanks & Regards,
ManiX.
mail2manix [at] gmail [dot] com
 
Hi Jurgen,
I'm looking for what you have done. Is it possible to share the code with me? My email is cg_mar@hotmai.com. Thanks in advance!
Guillermo
 
Hi Jurgen,

If you are still accessing this topic... I would appreciate if you email source code for the rich text column to slan_ska at yahoo dot com.
Thank you.
Slan
 
Hi Jurgen!

In case if you keep tracking this thread - I will appreciate if you could send me source code for this column to slan_ska at yahoo dot com.
Thanks in advance,
Slan
 
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.drawtobitmap.aspx

use DrawToBitmap
 
Any chance you share the code?
 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?