Click here to Skip to main content
Rate this: bad
good
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();
Controls.Add(outer.TestPage);
SaveBitmap();
//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.

            bmp.Save("C:\\Users\\Missak\\Desktop\\panel.jpg");
        }
Posted 2-Feb-13 11:03am
Edited 8-Feb-13 0:21am
v4
Comments
Sergey Alexandrovich Kryukov at 2-Feb-13 17:43pm
   
Why?! And what is "not working properly", exactly?
—SA
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...
—SA
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 http://stackoverflow.com/questions/14758374/wpf-print-richtextbox-as-image

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

  Print Answers RSS
0 CPallini 385
1 Sergey Alexandrovich Kryukov 262
2 OriginalGriff 200
3 George Jonsson 134
4 Richard MacCutchan 110
0 OriginalGriff 6,344
1 Sergey Alexandrovich Kryukov 5,890
2 CPallini 5,175
3 George Jonsson 3,559
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web03 | 2.8.140916.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