Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
210
Save UltraGroupBox or UltraPictureBox as an image with additional controls on it
posted

Hello team,

I am working on a new requirement for my project where  I need to save a group box as an image.

This groupbox has a UltraPictureBox in it and the UltrapictureBox has an image. On the image I placed some Activity controls. After I do some processing I need save the group box or the UltrapictureBox along with the activity controls on it as an image. Attached are the images which can provide a better insight of what my requirement is talking about. 

For some reason i am not able to see any Activity controls when I saved the group box control shown in image #2, Image # 3 is what is expected

I have the below code currently to achieve this but not helping out.

Bitmap bmp = new Bitmap(WaferMapultraGroupBox.ClientRectangle.Width, WaferMapultraGroupBox.ClientRectangle.Height);
WaferMapultraGroupBox.DrawToBitmap(bmp, WaferMapultraGroupBox.ClientRectangle);
using (Graphics g = Graphics.FromImage(bmp))
{
        g.DrawImage(bmp, 0, 0);
}

bmp.Save(filename, ImageFormat.Png);

Thanks in advance

Parents
  • 34810
    Offline posted

    Hello Baba Goud Gadiga,

    I have been investigating into this behavior you have described, and the current behavior you are seeing with the code you have provided is actually expected. The reason for this is that DrawToBitmap will only draw the control that you pass to it and not the child controls of that control. This is not something specific to Infragistics either – this will happen with built-in .NET Windows Forms controls as well.

    In order to achieve your requirement, I would recommend that you either recursively loop through the UltraGroupBox.Controls collection of your UltraGroupBox and draw them to the same Graphics object, or if you know the exact controls that you wish to draw, pick those out instead and draw them to a bitmap and then to your Graphics object.

    I am attaching a sample project that demonstrates how this can be done.

    Please let me know if you have any other questions or concerns on this matter.

    WindowsFormsApp91.zip

Reply Children