Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#
Hey I have a large panel in Ribbon Application , size of a page and it contains many other controls and a richtextbox. However DrawToBitmap is not working properly for richtextbox. I searched a little but it seems i have to print the screen. But i can't print because the page is a little big.
So is there another way to draw my panel with the richtextbox?
I am using this code.


OuterPages outer=new OuterPages();
//OuterPage is a class that contaings the panel TesPage and many controls in it //including RichTextBox.
       public void DrawControl(Control control, Bitmap bitmap)
            control.DrawToBitmap(bitmap, control.Bounds);
            foreach (Control childControl in control.Controls)
                DrawControl(childControl, bitmap);
        public void SaveBitmap()
            Rectangle rc = new Rectangle(0, 0, outer.TestPage.Width, outer.TestPage.Height);
            Bitmap bmp = new Bitmap(outer.TestPage.Width, outer.TestPage.Height);
            outer.TestPage.DrawToBitmap(bmp, rc);
            foreach (Control control in outer.TestPage.Controls)
                DrawControl(control, bmp);
          //  outer.TitleRichTextBox.DrawToBitmap(bmp, rc);  This is not working.

Posted 2-Feb-13 11:03am
Edited 8-Feb-13 0:21am
Sergey Alexandrovich Kryukov at 2-Feb-13 17:43pm
Why?! And what is "not working properly", exactly?
missak boyajian at 7-Feb-13 15:11pm
RichTextBox does not have DrawToBitmap method. How can I draw it?
missak boyajian at 3-Feb-13 5:58am
The text is not showing. It is just drawing the border.
Sergey Alexandrovich Kryukov at 7-Feb-13 15:32pm
This is not a complete code sample. What is, for example, outer? You could abstract it out, for example, some function without any unknown definitions, if not a complete project — the problem is simple enough.
Is it System.Windows.Forms? Always tag your UI library or application type...
missak boyajian at 8-Feb-13 6:25am
It's ribbon application. I have download it from component one studio. I improved the question. If still not enough I can improve it.
CHill60 at 8-Feb-13 11:19am
Have a look at this link

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CHill60 525
1 Sergey Alexandrovich Kryukov 469
2 OriginalGriff 325
3 PIEBALDconsult 285
4 BillWoodruff 193

Advertise | Privacy | Mobile
Web01 | 2.8.141015.1 | Last Updated 8 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100