We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback


Thread ID:





99746 Jun 8,2011 05:13 PM UTC Jun 21,2011 09:48 AM UTC WinForms 3
Tags: HTMLUIControl
Randolph Webb
Asked On June 8, 2011 05:13 PM UTC

I noticed a method on the control called DrawToBitmap. What does that do? How does it work? Will it draw to a bitmap any html I pass to it or just the whole control? I did notice it takes TargetBounds as one of it's parms. My interest is based on my need to create a drag image during mouse interactions. I could not find the link to the online doc for this method. Thanks.

- Randolph

Vallarasu S [Syncfusion]
Replied On June 9, 2011 05:20 AM UTC

Hi Randolph,

Thanks for your interest in Syncfusion products.

Control.DrawToBitmap method is inherited from Control, which paints the control into a bitmap. you can later use this bitmap to drag or paint to the form.

Place this code in the paint event of a form hosting a HTMLUIControl, and comment the following code from the designer generated code, which remove the control form the Form.Controls collection.

//this.Controls.AddRange(new System.Windows.Forms.Control[] {this.htmluiControl1});

Now you can notice the bitmap being drawn to the form.

Bitmap bmp = new Bitmap(300, 300);

// Renders the HTMLUIControl to the bitmap.
this.htmluiControl1.DrawToBitmap(bmp, new Rectangle(Point.Empty, bmp.Size));

/* Similarly you can call this piece of code.*/
// Graphics g = Graphics.FromImage(bmp);
// PaintEventArgs arg = new PaintEventArgs(g, new Rectangle(Point.Empty, bmp.Size));
// this.htmluiControl1.Document.Draw(arg, Point.Empty);

// Paints the bitmap to the form.
e.Graphics.DrawImage(bmp, Point.Empty);

// We have a DragHelper, you can make use of to perform this drag drop with this bitmap.
// Syncfusion.Windows.Forms.DragHelper

Please let me know if you need any further assistance.

Vallarasu S.

Randolph Webb
Replied On June 15, 2011 06:37 PM UTC

Hello Vallarasu,

Is there a function within the HTMLUI control that can return an image based on HTML I pass to it (with alpha channel ghosting/transparency)? Specifically, my use of the HTMLUI control is not to present the end user an interactive HTML document. My usage is just to paint the html of the underlying document. Given a click on the view presented to the end user, I need to be able to create an image of the control/area the user clicked on. I then intend to set that image as a cursor during a mousedown drag. It would be most ideal if there were a function to which I could pass some html and get back an image. Thanks,

- Randolph

Vallarasu S [Syncfusion]
Replied On June 21, 2011 09:48 AM UTC

Hi Randolph,

Thanks for the update.

You can make use of HTMLUIControl.DrawToBitmap and HTMLUIControl.Document.Draw methods to render the content of the controls as an Image as in the code snippet in my previous update.

Let me know if you need any further assistance on this.

Vallarasu S.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon