MGZ NetArt

Software Development and Support

Home
Design Patterns
C# Tips
AsyncCallback
Asynchronous Form.ShowDia
BackgroundWorker
Connection String
CopyTo() vs Clone()
Convert Color To String
Dispose vs Finalize
Debug mode
Delete Duplicate in SQL
Drag&Drop for TreeView
Edit Full Path Property
Hiding And Overriding
Polimorphism
How to use Resources
Run Time DLL
Simple Threading
Singleton Connection
Save Win Form as JPG File
Save Object in Registry
Soap Serialization
Sort and CompareTo
Working With List<>
Examples & Videos
MRDS Examples
Resume
Contact Us
If you need to save Win Form (or control in this example a Rich Text Box) as JPG file here is an example how to do it from the MDI parent menu:

// Determine the active child form.

Form activeChild = this.ActiveMdiChild;

if (activeChild is GraphViewWindow)

{

GraphViewWindow frm = activeChild as GraphViewWindow;

}

// If there is an active child form, find the active control, which

// in this example should be a RichTextBox.

if (activeChild != null)

{

try

{

RichTextBox theBox = (RichTextBox)activeChild.ActiveControl;

if (theBox != null)

{

Bitmap bmp = new Bitmap(theBox.Width, theBox.Height);

Graphics g = Graphics.FromImage(bmp);

Point myp = theBox.PointToScreen(new Point(0, 0));

Point myp1 = theBox.Location;

g.CopyFromScreen(myp, myp1, bmp.Size);

g.Dispose();

bmp.Save("FileName.jpg");

}

}

catch

{

MessageBox.Show("You need to select a Rich Text Box.");

}

}