This is a migrated thread and some comments may be shown as answers.

Combine controls into one image to load into RadCarousel

3 Answers 107 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
Rob Hedgpeth
Top achievements
Rank 2
Rob Hedgpeth asked on 28 Jun 2011, 03:44 PM
This question may belong in a different WinForms controls forum. If so, I apologize.

Ultimately, I am wanting to show a carousel full of RadGridViews, but for performance's sake I am converting the RadGridView's into RadImageItems to be loaded into the carousel.

I'd like to be able to put a label above the RadGridView as a title for the grid. So far I've tried adding a RadLabel and RadGridView to a RadItemsContainer, and then using the "GetAsBitmap" function to no avail.  

RadImageItem image1 = new RadImageItem();
image1.Image = rl.RootElement.GetAsBitmap(Brushes.White, 0, new SizeF(1, 1));
rl.RootElement.GetAsBitmap(Brushes.White, 0, new SizeF(1, 1));
 
RadImageItem image2 = new RadImageItem();
image2.Image = grid.RootElement.GetAsBitmap(Brushes.White, 0, new SizeF(1, 1));
 
RadItemsContainer ric = new RadItemsContainer();
ric.Items.Add(image1);
ric.Items.Add(image2);
 
RadImageItem image3 = new RadImageItem();
image3.Image = ric.GetAsBitmap(Brushes.White, 0, new SizeF(1, 1));
image3.ImageKey = imageKey;

(rl = previously declared RadLabel, grid = previously declared RadGridView)

Thanks,

Rob

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 01 Jul 2011, 09:44 AM
Hello Rob,

Thank you for the question.

We have never tested such a scenario before, but I would like to suggest that you to put a RadGridView and RadLabel into a Panel and call Panel.GetAsBitmap method.

Another possible solution is to try to combine two bitmaps - paint objects on different layers - here is an interesting article on how to do this.

I hope this helps.

Greetings,
Peter
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
0
Rob Hedgpeth
Top achievements
Rank 2
answered on 01 Jul 2011, 05:07 PM
Hey Peter,

Thanks for your response.

In case anyone ever has this same issue I was able to solve my problem by creating a bitmap of both the RadGridView and RadLabel, adding the images to a new Bitmap object, and then setting the RadImageItem's Image property to the new Bitmap.

//Previously instantiated grid
grid.BeginInit();
grid.BindingContext = new BindingContext();
grid.EndInit();
grid.LoadElementTree();
 
RadLabel descriptionLabel = new RadLabel();
descriptionLabel.Text = "Success!";
descriptionLabel.LoadElementTree();
    
Bitmap gridBitmap = grid.RootElement.GetAsBitmap(Brushes.White, 0, new SizeF(1, 1));
Bitmap labelBitmap = descriptionLabel.RootElement.GetAsBitmap(Brushes.White, 0, new SizeF(1, 1));
 
Bitmap bmp = new Bitmap(x, y, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
 
using (Graphics grfx = Graphics.FromImage(bmp))
{
   grfx.DrawImage(labelBitmap, 0, 0);
   grfx.DrawImage(gridBitmap, 0, 15);
}
       
RadImageItem image = new RadImageItem();
image.Image = bmp;

Thanks again,

Rob
0
Peter
Telerik team
answered on 06 Jul 2011, 01:41 PM
Hello Rob,

Thank you for the sharing this solution with the community.

Regards,
Peter
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Carousel
Asked by
Rob Hedgpeth
Top achievements
Rank 2
Answers by
Peter
Telerik team
Rob Hedgpeth
Top achievements
Rank 2
Share this question
or